event-sourcing | Provides basic functionality for event sourced aggregates | Microservice library

 by   prooph PHP Version: v5.7.0 License: BSD-3-Clause

kandi X-RAY | event-sourcing Summary

kandi X-RAY | event-sourcing Summary

event-sourcing is a PHP library typically used in Architecture, Microservice applications. event-sourcing has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.

Provides basic functionality for event sourced aggregates.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              event-sourcing has a low active ecosystem.
              It has 247 star(s) with 43 fork(s). There are 20 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 25 have been closed. On average issues are closed in 64 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of event-sourcing is v5.7.0

            kandi-Quality Quality

              event-sourcing has 0 bugs and 0 code smells.

            kandi-Security Security

              event-sourcing has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              event-sourcing code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              event-sourcing is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              event-sourcing releases are available to install and integrate.
              Installation instructions are available. Examples and code snippets are not available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed event-sourcing and discovered the below as its top functions. This is intended to give you an instant insight into event-sourcing implemented functionality, and help decide if they suit your requirements.
            • Load events from the snapshot .
            • Returns the root for the aggregate .
            • Get AggregateType from event root .
            • Create a new AggregateType from an aggregate root class .
            • Extracts the aggregate version .
            • Initialize from history .
            • Reconstruct the aggregate from history .
            • Replay the aggregate changes .
            • Replay stream events .
            • Generate mandatory options .
            Get all kandi verified functions for this library.

            event-sourcing Key Features

            No Key Features are available at this moment for event-sourcing.

            event-sourcing Examples and Code Snippets

            No Code Snippets are available at this moment for event-sourcing.

            Community Discussions

            QUESTION

            Event Sourcing in F#: what if aggregate state must be updated between events production?
            Asked 2022-Mar-21 at 01:06

            I just started diving into F# language and recently read an article about Event Sourcing in functional style and have some questions to clarify. There was the following command handler presented:

            ...

            ANSWER

            Answered 2022-Mar-21 at 01:06

            Disclaimer: I'm not an F# dev by any means, so will answer this in Scala.

            Remember that you have the event-handling function available (because your aggregate is defined by the pair of the event handler and the command handler):

            Source https://stackoverflow.com/questions/71540913

            QUESTION

            How do I properly design Aggregate in DDD, Event-sourcing
            Asked 2022-Mar-08 at 16:01

            Suppose I want to make an e-commerce system. I have 2 aggregates here ProductAggregate and UserAggregate. Product aggregate contains productId, price. User aggregate contains userId and balance. Here's the problem, in event-sourcing we should not rely on the read model since there might be eventual consistency problem. Ok so we should rely on the command model right I guess?, but this two command model is different. I read from somewhere else they told me that aggregate should only rely on its state. Let's say the user want to buy a product I have to check if he has enough balance and in order to do that I need to know the price of product. So read model not allowed, aggregate query not allowed. what options do I have here?

            ...

            ANSWER

            Answered 2022-Mar-08 at 16:01

            First of all, regarding your handle, you're not stupid :)

            A few points:

            • In many situations you can query the read model even though there's eventual consistency. If you reject a command that would have been accepted had a pending update become visible in the read model, that can typically be retried. If you accept a command that would have been rejected, there's often a compensating action that can be applied after the fact (e.g. a delay between ordering a physical product and that product being delivered).

            • There are a couple of patterns that can be useful. One is the saga pattern where you would model the process of a purchase. Rather than "user A buys product X", you might have an aggregate corresponding to "user A's attempt to purchase product X", which validates and reserves that user A is able to buy X and that X is able to be purchased.

            • Every write model with an aggregate implies the existence of one sufficiently consistent read model for that aggregate. One can thus define queries or "read-only" commands against the write model. CQRS (IMO) shouldn't be interpreted as "don't query the write model" but "before trying to optimize the write model for reads (whether ease, performance, etc.), give strong consideration to handling that query with a read model": i.e. if you're querying the write model, you give up some of the right to complain about the queries being slow or difficult. Depending on how you're implementing aggregates this option may or may not be easy to do.

            Source https://stackoverflow.com/questions/71374492

            QUESTION

            Simple "CRUD" read on Axon aggregate
            Asked 2022-Jan-13 at 11:16

            What's the simplest way to do a basic GET on the Aggregate in a REST-Axon program, without AxonServer?

            • I have a simple springboot Axon-and-REST application with an aggregate FooAggregate.
            • I create the Foo with a POST /foos which send a command on the command gateway, etc.
            • I query the list of all Foos by actually querying GET /foo-summaries, which fires query objects on the query gateway, and returns where FooSummary objects, where FooSummary is a JPA entity I create in a projection that listens to FooCreated and FooUpdated events.

            All standard stuff so far. But what about simple GET /foos/{id} ?

            That URL /foo/{id} is what I want to return in the Location header from POST /foos And I want this GET to return all of the details of my Foo - all of which are modeled as properties of the FooAggregate (the FooSummary might return a subset for listing)

            Now, Axon documentation suggests this:

            Standard repositories store the actual state of an Aggregate. Upon each change, the new state will overwrite the old. This makes it possible for the query components of the application to use the same information the command component also uses. This could, depending on the type of application you are creating, be the simplest solution.

            But that only applies if I use state-stored aggregates, right? I'm using Event-Sourced aggregates, with a JPA eventstore.

            My options would appear to be:

            1. Forget about the event-sourcing and use the stored-state aggregate approach, as suggested as being the 'simplest' approach (I don't have any specific need to event source my aggregate - although I am definitely event sourcing my projection(s)

            2. Keep the full details in my FooSummary projection table, and direct GET /foo/{id} to there with a slightly different query than GET /foo-summaries (alternative, just call it GET /foos and return summaries)

            3. Create a separate "projection" to store the full Foo details. This would be effectively identical to what we would use in the state-stored aggregate, so it seems a little weird.

            4. Some 4th option - the reason for this question?

            ...

            ANSWER

            Answered 2022-Jan-13 at 11:16

            Answering my own question, but really the answer came from a discussion with Christian at Axon. (Will leave this open for a few days to allow for better answers, before accepting my own :))

            My options #2 and #3 are the right answers: the difference depending on how different my "summary" projection is from my "detailed" projection. If they're close enough, option #2, if they're different enough #3.

            Option #1 is non-ideal, because even if we were using state-stored for some other reason, basing queries on the state-store breaks the Segregation that is the 'S' in CQRS: it makes our query model depend on our command model, which can lead to problems when our model gets more complex.

            (Thanks Christian)

            Source https://stackoverflow.com/questions/70682869

            QUESTION

            How to correctly persist and present information from multiple aggregates?
            Asked 2021-Nov-20 at 07:32

            I'm creating a selling platform. The core aggregate is called Announcement and it holds references to other aggregates such as Categories, User etc. I am using CQRS approach an event-sourcing solution as storage.

            For performance reasons, I decided to store some important details about associated objects (Categories, User) inside the Announcement aggregate along with their ids. My reasoning behind it was that when filtering announcements, I want to simplify the access to those information as much as possible (reduce the number of database joins, allow fancy querying syntax). It was possible, because I included all the required information in the command, which creates an announcement. Generation of a detailed view of an announcement is based on information embedded inside the aggregate. Although it seemed reasonable at first, now I'm having second thoughts.

            The considerations that made me think are:

            • I realized that I don't need transactional consistency on all the additional details (categories, seller details, etc.). There are no constraints that would force me to do what I did.

            • The event store that I'm using offers multistream projections. I'm wondering if that's the puzzle piece that should replace the redundant information in the Announcement aggregate.

            Are the following steps a valid solution for the described problem?

            1. Remove the duplicated information from the Announcement aggregate;
            2. Use a domain event to notify other aggregates about creation of an Announcement;
            3. Let other aggregates publish appropriate events in response to the AnnouncementCreated event; these events may contain additional information about associated objects;
            4. Introduce a multistream projection, which will update itself in response to events from multiple aggregates and produce a complete view of the announcement;
            ...

            ANSWER

            Answered 2021-Nov-19 at 15:31

            In general, the only reason to include data in a particular aggregate is if that data affects command validation or if there's some other consistency demand. if information about categories or users isn't qualifying under either reason, then it makes a lot of sense to remove it from the announcement aggregate.

            I would probably consider modeling a "categorized and associated announcement" aggregate which is fed by domain events from announcement/category/user aggregates. This could be implemented via the multistream projection from your event store, but I think it's useful to keep that detail separate because there are other ways you could feed domain events from multiple aggregates as commands for a different aggregate (the command implicit in any event is "incorporate this event into your view of the world").

            Source https://stackoverflow.com/questions/70036104

            QUESTION

            What's the difference between Red Hat OpenShift Streams and AMQ Streams
            Asked 2021-Nov-16 at 15:15

            I am designing an Event-Sourcing architecture with Kafka on Openshift. I have recently seen that Red Hat has a module called Red Hat AMQ Streams in the "Integration boundle" (not free of course).

            However I have discovered what red hat call "Openshift Streams" and it looks "free cost". I would like to know the diferences between both services. Thank you!

            ...

            ANSWER

            Answered 2021-Nov-16 at 15:15

            Both products are based on Kafka and Strimzi.

            Red Hat OpenShift Streams for Kafka is a hosted solution. It's not free cost (although there are free trials for developers).

            AMQ Streams is also based on Kafka and Strimzi but is customer hosted and managed. As you point out it's part of the overall integration bundle (so is therefore also going to include other related components like Debezium.) It has a more traditional cost model around number of cores that you use.

            Source https://stackoverflow.com/questions/69885560

            QUESTION

            How to setup akka persistence project
            Asked 2021-Jul-27 at 21:40

            I'm attempting to run the sample project from How to setup akka persistence project : https://developer.lightbend.com/start/?group=akka&project=akka-samples-persistence-dc-java

            When I try to run the example using the command :

            mvn exec:java -Dexec.mainClass="sample.persistence.multidc.ThumbsUpApp" -Dexec.args="cassandra"

            I receive the error:

            ...

            ANSWER

            Answered 2021-Jul-27 at 14:57

            It seems you are referencing a class name that doesn't exist in the project source. You may use the following command instead.

            Source https://stackoverflow.com/questions/68522161

            QUESTION

            CQRS with event driven architecture but without event sourcing
            Asked 2021-May-11 at 14:43

            Before posting this, I referred many sites and learning platforms but saw similar pattern of developing CQRS with event sourcing. Again to have proper events you need to follow DDD pattern. I have below questions.

            1. Can we keep read and write DB in sync just by publishing event from write model and consume it at read model using event handler and updating read database
            2. Why Event-Sourcing and replay of events needed if my requirement is to only see latest data
            3. I can manage audit of data as and when events reaches at event handler
            4. I can version messages based on timestamp in case if race condition.
            5. Please explain by doing steps 1,3 and 4, am I still following CQRS pattern?

            FYI, I am using .NetCore 3.1, AWS Lambda services, MassTransit as a MessageBus and SQS as a transport.

            Thanks in advance.

            ...

            ANSWER

            Answered 2021-May-11 at 14:30

            As soon as you have separate data models for reading and writing, you're following CQRS. Event sourcing is not strictly required.

            Note that accomplishing 1 in an application in a way which preserves the expected eventual consistency of the read side with the write side is rather difficult. You'll need to ensure that you publish the event if and only if the update of the write DB succeeded (i.e. there's never a case where you publish and don't update nor is there ever a case where you update but don't publish: if either of those could happen, you cannot guarantee eventual consistency). For instance, if your application does the update and if that succeeds, publishes the event, what happens if the process crashes (or you get network partitioned from the DB, or your lambda exceeds its time limit...) between the update and publishing?

            The 2 best ways to ensure eventual consistency are to

            • update the write side DB by subscribing to the published event stream
            • use change data capture on the write side DB to generate events to publish

            The first is at least very close to event sourcing (one could argue either way: I'd say that it depends on the extent to which your design considers the published event stream the source of truth). In the second, remember that you've basically lost all the contextual domain knowledge around the what's happened around that event: you're only seeing what changed in the DB's representation of the model.

            Event sourcing and CQRS mutually improve each other (you can event source without doing CQRS, too, though it's only in certain applications that ES without CQRS is practical); event sourcing tends to let you keep the domain front-and-center and since it's append-only, it's the most optimized write model you can have.

            Source https://stackoverflow.com/questions/67487981

            QUESTION

            Event sourcing and Domain Event
            Asked 2021-May-11 at 03:53

            What is Event sourcing and what is Domain Event.

            I read both the articles and I am not be able to get it properly. So, please describe it in easy words.

            And what is the difference between them?

            Are domain events and event driven are same?

            ...

            ANSWER

            Answered 2021-May-02 at 13:46

            Not your fault: the literature is a mess.

            Domain events, event sourcing, and event driven are three different ideas that happen to share the label "event".

            Domain events are a domain modeling pattern; in effect making "things that happen" a first class citizen in your domain model. Think BookSold, not MouseClicked

            Event sourcing is a data modeling pattern; instead of having a domain entity with mutable properties, we have a domain entity with a history of changes.

            Event driven is a communication pattern; system A publishes an event, and system B reacts. Notice that system A and system B don't even need to know about each other; the only need a common undertanding of the event, and shared plumbing (aka middleware).

            Source https://stackoverflow.com/questions/67356709

            QUESTION

            Event Sourcing and cqrs with eventstore db
            Asked 2021-Mar-16 at 15:59

            store db and event-sourcing, but I have doubts regarding projections and cqrs. So far this is the way in which I call my commando and my command handler:

            create-user-command

            ...

            ANSWER

            Answered 2021-Mar-16 at 15:59

            In CQRS, when using EventStoreDb, your aggregate must be designed to be restored to a state from Events. Events are stored in a stream with a unique name and identifier (guid). When modifying the aggregate, you must read this stream, and apply each event in sequence to restore the current state, before executing any changes to the aggregate (which generates more events). In order to maintain integrity and handle optimistic concurrency, you should have a simple version check in your aggregate which counts the old events + new events to ascertain to latest version number to be persisted.

            The issues I see above are as follows. Your aggregate has a constructor and a static method which generates events without any validation of the current state i.e.: What happens if I call create twice with the same guid?

            this.apply(new UserCreatedEvent(guid, {email, name}, new Date()));

            You are applying state here directly. Instead, you should raise the event inside your Create method.

            this.raiseEvent(new UserCreatedEvent(guid, {email, name}, new Date()));

            This should be implemented to do the following.

            • Added to a list of uncommitted events
            • this.apply called

            You should then persist the events to the EventStoreDb in your command handler.

            Source https://stackoverflow.com/questions/66614827

            QUESTION

            How to implement Event sourcing and a database in a microservice architecture?
            Asked 2021-Feb-02 at 04:18

            I have been learning lately about microservices architecture and it's features. in this source it appears that event sourcing is replacing a database, however, it is later stated:

            The event store is difficult to query since it requires typical queries to reconstruct the state of the business entities. That is likely to be complex and inefficient. As a result, the application must use Command Query Responsibility Segregation (CQRS) to implement queries.

            In the CQRS Page the author seems to describe a singular database that listens to all events and reconstructs itself.

            My question(s) is:

            What is actually needed to implement event sourcing with a queryable database? particularly:

            Where is the events database? Where is the queryable database? Do I need to have multiple event stores for every service or can I store events in a message broker like Kafka? is the CQRS database actually is one "whole" database that collects all the events? And how can all of this scale?

            I'm sorry if I'm not clear with my question, I am very confused myself. I guess I'm looking for a full example architecture of how things will look in the grand picture.

            ...

            ANSWER

            Answered 2021-Feb-02 at 03:50

            Event Source is not replacing the DB. It has some benefits and challenges. So, we should choose it wisely. If you are not comfortable then don't choose it. You can implement Microservice Style without event sourcing.

            Query able DB - Simple solution is to implement CQRS pattern and keep your Query DB in sync with Event Source DB.

            Event DB should be with owner service like if you are keeping events about Order than it should be in Order service. (Yeah, other service can have replica of the same).

            You may use Kafka as intermediate storage for event but not the final one.

            CQRS is not about one DB. It an pattern where we use to DB models, one is for Command and Another one is for Query.

            If you understand Java then please refer Book "Microservice Patterns - Chris Richardson" and if you are from C# or Microsoft technology stack then you may refer "https://github.com/dotnet-architecture/eShopOnAzure".

            Source https://stackoverflow.com/questions/66000270

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install event-sourcing

            You can install ProophEventSourcing via composer by adding "prooph/event-sourcing": "^5.0" as requirement to your composer.json.

            Support

            Ask questions on Stack Overflow tagged with [#prooph](https://stackoverflow.com/questions/tagged/prooph). File issues at [https://github.com/prooph/event-sourcing/issues](https://github.com/prooph/event-sourcing/issues). Say hello in the [prooph gitter](https://gitter.im/prooph/improoph) chat.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/prooph/event-sourcing.git

          • CLI

            gh repo clone prooph/event-sourcing

          • sshUrl

            git@github.com:prooph/event-sourcing.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link