Skip to main content

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:​

EntytyDescription
domainBusiness domain, like player, wallets, games, etc
bounded_contextBounded context of business domain, like favorite_games
modifierModifier 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​

FieldTypeRequiredDescription
event_versionstringβœ”Event version.
timestamptimestampβœ”Event timestamp
actionstringβœ”Add / remove / credit / debit etc..
tracingbooleanβœ”Need to send tracing events.
dataobject βœ”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

How to promote new domain events​

Major changing of existing domain events​