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

Add requestProgress function to Watch and Watcher interfaces #957

Merged
merged 1 commit into from
Jul 30, 2021

Conversation

juliankung-db
Copy link
Contributor

Added a requestProgress function to the Watch and Watcher interfaces to request a WatchResponse be sent to all watchers containing the latest revision number. This can be used to check if a watcher is "caught up" to a particular revision, which is useful when determining if a watch cache is stale by comparing the progress revision to the revision returned in a quorum read.

This was added to the etcd client in etcd-io/etcd#9869 and requested for the jetcd client in #928

Commit message below

Added a function that requests a watch stream progress status
be sent in the watch response stream as soon as possible. This is
helpful in situations where an application may want to check the
progress of a watch to determine how up-to-date the watch stream is.

Addresses #928

@juliankung-db juliankung-db force-pushed the progressNotifyRequest branch 2 times, most recently from d62d2e4 to eef02e7 Compare July 29, 2021 17:31
@Override
public void requestProgress() {
if (!closed.get()) {
synchronized (this.lock) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we can send a single RequestProgress update at this point (we'd need to add a FutureStub property if we go this route) and we can propagate the response to all watchers.

This'll save the etcd server from getting hit with multiple requests if there are multiple watchers

Copy link

@mikehuston mikehuston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some doc nits, of course defer to maintainers

jetcd-core/src/main/proto/rpc.proto Outdated Show resolved Hide resolved
jetcd-core/src/main/java/io/etcd/jetcd/Watch.java Outdated Show resolved Hide resolved
jetcd-core/src/main/java/io/etcd/jetcd/Watch.java Outdated Show resolved Hide resolved
docs/Watch.md Outdated
@@ -44,6 +46,13 @@ Cancel the watch task with the watcher, the `onCanceled` will be called after su
1. The watcher will be removed from [watchers](#watchers-instance) map.
2. If the [watchers](#watchers-instance) map contain the watcher, it will be moved to [cancelWatchers](#cancelwatchers) and send cancel request to [requestStream](#requeststream-instance).

## requestProgress function

Send the most updated revision number to all active [watchers](#watchers-instance)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send the latest revision processed by each watcher to all... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to be similar to what you suggested

docs/Watch.md Outdated
# Implementation

The etcd client process watch request with [watch function](#watch-function), process notification with [processEvents function](#processevents-function) , process resume with [resume function](#resume-function) and process cancel with [cancelWatch function](#cancelwatch-function).
The etcd client process watch request with [watch function](#watch-function), process notification with [processEvents function](#processevents-function) , process resume with [resume function](#resume-function), process cancel with [cancelWatch function](#cancelwatch-function) and process progress with [requestProgress function](#requestProgress-function).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The etcd client process watch request with [watch function](#watch-function), process notification with [processEvents function](#processevents-function) , process resume with [resume function](#resume-function), process cancel with [cancelWatch function](#cancelwatch-function) and process progress with [requestProgress function](#requestProgress-function).
The etcd client process watch request with [watch function](#watch-function), process notification with [processEvents function](#processevents-function) , process resume with [resume function](#resume-function), process cancel with [cancelWatch function](#cancelwatch-function) and [requestProgress function](#requestProgress-function).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to be more clear

// For watch progress responses, the header.revision indicates progress. All future events
// received in this stream are guaranteed to have a higher revision number than the
// header.revision number.
rpc Progress(WatchProgressRequest) returns (WatchResponse) {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rpc Progress(WatchProgressRequest) returns (WatchResponse) {}
rpc ProgressRequest(WatchProgressRequest) returns (WatchResponse) {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if improvement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this for the maintainers to decide. I was following what looked like the proto pattern for RPCs in the file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go with Progress so it uses the same pattern

Added a function that requests a watch stream progress status
be sent in the watch response stream as soon as possible. This is
helpful in situations where an application may want to check the
progress of a watch to determine how up-to-date the watch stream is.

Addresses etcd-io#928
@juliankung-db
Copy link
Contributor Author

@lburgazzoli would you mind merging when you have the chance? I don't have write access so I can't do it myself

@lburgazzoli lburgazzoli merged commit b83f6bf into etcd-io:master Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants