Skip to main content

Echo

In a distributed system it may be difficult to deduce which event occurred when. But the database is the final point of certainty. Therefore, we can surely say that if a database transaction is completed successfully the event is actually occurred at the transaction execution.

If a user completes an action successfully, some database table will get updated. For example if user sends a withdrawal request, some table in database will have a record that contain the withdrawal request details.

To notify the user in realtime with absolute certainty, these data changes are published via pg_notify to z_event_stream channel and echo will capture these changes.

Database messages

Pg_notify messages have following fields.

FieldTypeDesc
e_idnumberGlobal private event id
e_tsnumberEvent timestamp in ms
e_srcstringEvent code
e_usernumberUser id
e_detailjsonEvent details

Published messages

Echo will reformat received messages in a more friendly way and publish the reformatted messages via websocket.

{
"event": "user",
"ts": 1757491799565,
"eid": 64460367,
"user_id": 2801682,
"data": {
"levelId": [
3,
3
],
"status": [
0,
0
],
...
}
}

Published messages will be captured from socket relay project as private events and socket relay will publish the event details to users' private socket channel.