-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronous room callbacks + documentation #75
Comments
Hey @msackman, these are some good points & improvements for the SDK.
It's not entirely consistent today. For events originated from a participant, they are triggered synchronously. However, some of the room events are being triggered in their own goroutines.
blocking calls would be an issue here, so it's ideal to avoid performing heavy processing within the callbacks.
For this reason, I think we should move to a model that fires events synchronously. clients should handle blocking queries / spin up goroutines as appropriate. it's unlikely, but possible for webhooks to see events out of order too. We do include a timestamp of the event, but that is in seconds, and likely not granular enough. we could include a nanosecond timestamp in addition to that. wdyt? |
Hi @davidzhao My preference is the same as yours: a single go routine invokes all callbacks per room, in a blocking fashion. And the docs make clear that it's your responsibility to not block for very long. The user could then send them all into a channel as a reasonable way to not block the server, but maintain correctly ordered events. For the webhooks, personally I always prefer seeing a simple counter (if it's good enough for TCP, it's good enough pretty much everywhere else too!). Yes, a nanosecond timestamp would very likely do, but then it always risks implying more - eg exactly when within the event was this timestamp taken? So if it was me doing it, I would have a simple |
Oh I just thought of something else; apologies if I'm stating the obvious: |
a plain counter would definitely work, but would make it trickier for distributed rooms (in the future). Generally speaking, we are moving to a timed verion system in all of our cross-node communication, which we might end up using for webhooks too. It's also known as a hybrid clock |
Curious. Ok, I've not come across hybrid clocks before. And basically because of that I'd have probably picked vector clocks, simply because I know them very well. Either way, it means that you can no longer have a total order of events, right - if you're going for truly distributed rooms with no "leader" node, then events can be truly concurrent. I wouldn't be surprised if that raises a lot of challenges. |
I have some questions about the correct way to use RoomCallbacks, and I can't find any documentation. If someone could answer the following questions then I would happily write the documentation and send in a PR.
Because of 4, I would really love to see a chan of events and some guarantee that the events on that chan reflects the total order of events as they happened in the room.
(I'm also curious how this impacts the webhooks. I wonder if they suffer from the same challenges - particularly with ordering).
The text was updated successfully, but these errors were encountered: