Events
Events are divided into two types. Local which are necessary for the implementation of the event-driven approach and domain events.
info
Be careful when modifying, deleting and adding a new domain event. This is the basis for communication between our services. Details on how to make such changes can be found in the section Rules to promote new domain event.
Domain eventsβ
@todo: Domain and bounded context detection
Event name conventionβ
All domain names must adhere to a naming convention.
Naming pattern:
[env?].[domain].[bounded_context].[action]
info
For some environments with multi-instance may used env prefix
Description:β
| Entyty | Description |
|---|---|
| domain | Business domain, like player, wallets, games, etc |
| bounded_context | Bounded context of business domain, like favorite_games |
| modifier | Modifier is optimisation of event payload, all events has action name, that mean's what we do with our bounded context |
Exampleβ
Favorite game service fire
player.favorite_games.change
Valid event nameβ
- must be 63 characters or less,
- must begin and end with an alphanumeric character ([a-z0-9A-Z]),
- could contain dashes underscores (_), dots (.), and alphanumerics between.
Event protocolβ
This protocol is used for event-sourcing and event-driven.
Descriptionβ
| Field | Type | Required | Description |
|---|---|---|---|
event_version | string | β | Event version. |
timestamp | timestamp | β | Event timestamp |
action | string | β | Add / remove / credit / debit etc.. |
tracing | boolean | β | Need to send tracing events. |
data | object | β | Strong structured event data |
For serialisation and schema management we using avro schema and avro schema registry
Exampleβ
Example with Avro Schema
export default {
name: 'FavoriteChange',
scheme: avro.Type.forSchema({
type: 'record',
namespace: 'favorite.games',
name: 'Action',
fields: [
{ name: 'event_version', type: 'int' },
{ name: 'timestamp', type: 'long' },
{
name: 'action',
type: {
type: 'enum', name: 'action', symbols: ['ADD', 'DELETE']
}
},
{ name: 'tracing', type: 'string' },
{
name: 'data',
type: {
type: 'record',
fields: [
{ name: 'user', type: 'string' },
{ name: 'game_id', type: 'string' }
]
}
}
],
}),
};
Create or change domain eventsβ
- 1 Event - 1 topic
@todo: Process of promotion