Event synchronization mechanism
The event synchronization mechanism provides a channel for publishing events that occur within the collaborative engine. The client system can consume these events and combine them with its own business to take the next step.
How to use event synchronization mechanism?
Currently supported for collaborative event synchronization:
- Collaborative editing: changeset successfully stored
How to use event synchronization mechanism
Starting to use the event synchronization mechanism is very simple.
- Turn on event synchronization switch
- Initiate Consumer Event
Turn on event synchronization
Add these configs below to your customer config file, go to [Deploy to product environment(/guides/sheets/pro-features/server/deploy) to learn how to apply customer configs.
add this to your .env.custom
EVENT_SYNC=true # true for turn on
Code Snippet for consumer
Refer to https://github.com/dream-num/univer-event-sync-example-go
Data structures
message EventSyncData {
string eventId = 1;
string eventType = 2; // type of event, now support changeset
int32 createdAt = 3;
oneof event {
univer.ChangesetAck csAckEvent = 4;
// more event types in the future.
}
}
message ChangesetAck {
univer.Changeset cs = 1;
}
message Changeset {
string unitID = 1; // unitID of the Univer document
univer.constants.UniverType type = 2;
int32 baseRev = 3;
int32 revision = 4;
string userID = 5;
repeated Mutation mutations = 6;
string memberID = 7;
}
message Mutation {
string id = 1; // ID of the mutation
string data = 2; // serialized params
}