Skip to content
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

[feature] Access to channel offset and epoch #446

Closed
gazugafan opened this issue Apr 29, 2021 · 3 comments
Closed

[feature] Access to channel offset and epoch #446

gazugafan opened this issue Apr 29, 2021 · 3 comments
Milestone

Comments

@gazugafan
Copy link

From the discussion here: centrifugal/centrifuge-js#44 (comment)

It would be nice to be able to get a channel's offset and epoch--especially after publishing a message. Ideally, I'd like the publish command to respond with the newly published message's offset and epoch--similar to how NCHAN works. Or perhaps there could be a new command to retrieve a channel's current offset and epoch?

This would help solve the problem where, after loading the application state during the initial page request, messages are published (and missed) in the few seconds before the client can establish a subscription connection.

Instead, we could send the current offset and epoch along with the current application state during the initial page request, and then include this offset and epoch when the client subscribes.

It would be extra nice if the centrifuge-js (and other) client libraries could accept an offset and epoch right in their subscribe methods--automatically retrieving and playing back any messages missed afterwards. I think the existing history method is probably enough to accomplish this already, but that would require a little extra work and I'd be worried the timing might not be quite perfect.

@FZambia
Copy link
Member

FZambia commented Sep 2, 2021

Done in v3, introduction blog post.

Offset and epoch now returned in publish result if channel stream has history enabled.

@gazugafan, centrifuge-js 2.8.0 also contains a way to access StreamPosition in SubscribeSuccessContext (in channels with history enabled and position or recover options on). And a way to subscribe from certain StreamPosition and thus manually activate recovery process. Also it's possible to bypass recovery mechanism and implement manual message recovery from history stream using history iteration API (available in client and server API). Feel free to reach me out with any questions – would be awesome to know whether this all worked for you eventually.

One thing to mention is that our existing HTTP API client libraries not all updated yet to support publish result with additional fields. But since it's a simple HTTP POST request - should not be a blocker I believe. Also possible to use GRPC server API and generate code for publisher side.

@gazugafan
Copy link
Author

Amazing! Excited to try out v3 soon. Will report back when I do :D

@FZambia
Copy link
Member

FZambia commented Nov 12, 2021

Closing, feel free to continue writing here in case of any feedback.

@FZambia FZambia closed this as completed Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants