Evently Concepts
Entity
An Entity can be anything that has distinct state in a domain, such as a shopper, a rental car, or a hotel room. An entity instance is identified by its key, often a business identifier string. An event can affect multiple entities at the same time, so this field accepts multiple entity values to capture this state.
Events
An event records that something has occurred to an entity or set of entities. Events are immutable, meaning they cannot be altered, and irrevokable, meaning they cannot be deleted out of the ledger. An event has a name, entity identifiers, data and meta information.
Here is an example of an event named Item Ordered:
{copyText = 'Copy'}, 300)" class="language-json">{
"event": "Item Ordered",
"entities": {
"patron": ["Harold_Cho"]
},
"eventId": "0005d0df8d1e990f13658533a0f8f294",
"timestamp": "2021-11-16T03:30:47.430415Z",
"data": {
"menuItem": "Bean Burrito",
"toppings": ["chiles", "salsa verde"],
"spicy": true,
"peppers": 5
},
"meta": {
"actor": "register-2",
"commandId": "e33692e9-3e73-4028-8962-2753ddae2a0f",
"correlationId": "22341"
}
}
The entities identifier is the entity type and list of keys. In this example, the entity is identified as entity type patron with the key Harold_Cho.
The meta field contains data that can be applied to any event. In this system, the value includes the actor and a commandId which has meaning to the application. Your application can store any values in the meta field.
All values in an event's data and meta fields can be queried with Selectors.
Ledger
The ledger stores events that have been appended by an application. Applications append events to a ledger and retrieve events from a ledger using a Selector. Ledgers have ACID properties, similar to relational databases.
Selectors
Applications find relevant events with selectors. A selector object tells the Ledger which events to select and return to the application.
Selector statements can contain a limit property to control the number of events to be retrieved. Additionally they can contain an after property to indicate where to start selecting events from. Together these two properties can be used to page through large selector results.
Ledgers accept two types of selectors–replay and filter selectors.
Replay Selectors
The replay selector states the entity type, instance keys, and events of interest. Applications use replay selectors to “hydrate” entity state for presentation or business logic purposes.
{copyText = 'Copy'}, 300)" class="language-json">{
"entities": {
"game": ["Zirommok_Dun_&_Bradstreet_Inc._1968_Championship~15_1"]
},
"events": ["game-started", "game-finished"]
}