-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Watch a path, including the current content #7362
Comments
It doesn't work like this. Rev=0 is treated like the current revision + 1-- it will block until the next update. Approach 2 is the way to do it. It's a little clunky but it better respects the stream semantics of grouping events together as revision updates. This is essentially what |
@heyitsanthony oh yeah I think you are right about |
@derekchiang yes, it will stream all the updates since |
@heyitsanthony thanks for the clarification. I will close this issue since the |
What is the best way to watch a particular prefix
p
, while having the stream include the current objects that match the prefix?I have come up with two approaches so far, neither of which seems ideal:
Approach 1
In this approach, you use the
WithRev(0)
option withWatch
. That way, all events since the beginning of time get returned (other than those already GC-ed).The downside is that you also get really old events that you don't care about anymore. For instance, if an object was added but subsequently removed, you don't really want to receive the
PUT
andDELETE
events. It'd be ideal if the stream was smart enough to just not tell you about that object at all.Approach 2
In this approach, you use a
Get
to get all the current objects first. Then, you issue theWatch
with the optionWithRev(t)
where t is the revision time stamp you got from theGet
.The downside of this approach is that it's cumbersome. You have to use a
Get
and aWatch
.So I guess my question is, is there a better approach that I'm not aware of, and if not, would it be a good idea to have something like a
WithCurrent
option built into etcd that would include the current objects in the watch stream?The text was updated successfully, but these errors were encountered: