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

provides well documented lease example #840

Merged
merged 4 commits into from
May 18, 2020
Merged

Conversation

OlegDokuka
Copy link
Member

Provides a good example which shows how Lease can be used for the straight-forward rate-limiting of FireAndForget calls

Signed-off-by: Oleh Dokuka shadowgun@i.ua

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

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

Nice example. I've added a few suggestions below.

Do we still need the LeaseExample? It's not connected to the lease notifications from the remote it seems, and retries blindly every second. In any case it doesn't seem to demonstrate anything extra so perhaps this can just replace it.

try {
while (!Thread.currentThread().isInterrupted()) {
String message = messagesQueue.poll(Long.MAX_VALUE, TimeUnit.DAYS);
System.out.println("Process message {" + message + "}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace all System.out with a Logger.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

String.format("%s stats are %s", tag, leaseStats.isPresent() ? "present" : "absent"));
Duration ttlDuration = Duration.ofSeconds(5);
// The interval function is used only for the demo purpose and should not be
// considered as the way to issue leases.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to describe what would be used instead of interval?

Copy link
Member Author

Choose a reason for hiding this comment

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

OlegDokuka and others added 2 commits May 18, 2020 14:34
…cp/lease/RateLimitingWithLeaseExample.java

Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Co-authored-by: Rossen Stoyanchev <rstoyanchev@users.noreply.github.com>
Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka OlegDokuka merged commit ff4d516 into master May 18, 2020
@OlegDokuka OlegDokuka deleted the docs/lease-example branch May 18, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants