-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Enhancement: Allow watch from "first available index" vs. new updates or updates from a valid start index #1666
Comments
I am not entirely sure I understand your use case exactly. What if you simply do watch with |
On rereading, it sounds like you mean you want the "first index in the currently available history", but I'm unclear on what the use case for that would be. |
Yes, I want to basically be able to fetch the full history from whatever point it is. The use case is slightly odd. I am thinking of using etcd to add clustering to a simple pubsub system I have, by having my current publishers send message to etcd and having multiple pubsub services watch the message "queue" (the message queue in this case would be a single "key" or multiple keys if I want to support sharding). When everything is working fine the pubsub services should be able to keep up with updates to the "queue" and process them, but if one of the pubsub services is restarted I would like to be able to process as many messages I can (and I know that I may be missing some, but it's fine in my particular use case). But given that etcd does some "buffering" I would like to be able to process the buffered messages. |
Just to be clear, the current documentation for watch says "Using the index, we can watch for commands that have happened in the past. This is useful for ensuring you don't miss events between watch commands." If a client waits "too much" between calls to watch currently it gets an error and the options are:
My proposal is to add an option to say "I am ok loosing some messages, just give me all that is available after this index". I know I'll be losing some, but I know how many messages I have lost (and can decide to abort or continue from there) |
This is a reasonable feature and I think it should be straightforward to implement. But, I don't think it will make it into the 0.5.0 release so I will put it on 0.6.0-maybe. If you want to submit a PR that would be great. |
Great! Thanks! -- Raffaele
|
#4495 can do this in v3.
|
Currently watch requests only allow watchIndex=0 (new updates) or watchIndex >= start index (start from watchIndex). I would like to be able to get all available updates without having to specify a valid watchIndex.
Something like watchIndex = -1 means "start from first available" or an extra flag to allow watchIndex < startIndex (again, it would start from first available).
With the current implementation I need to parse the error message ("the requested history has been cleared [%v/%v]") and resubmit the request with the current startIndex, but if more updates are published while doing this I may never get to fetch any valid value.
I am happy to submit a pull request if we can agree on the interface (watchIndex < 0 or new flag)
The text was updated successfully, but these errors were encountered: