Skip to content

provides well documented lease example #840

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

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 [email protected]

@OlegDokuka OlegDokuka added this to the 1.0.1 milestone May 15, 2020
@OlegDokuka OlegDokuka requested a review from rstoyanchev May 15, 2020 21:42
@OlegDokuka OlegDokuka force-pushed the docs/lease-example branch from 4b71165 to 2680d32 Compare May 15, 2020 22:00
@OlegDokuka OlegDokuka force-pushed the docs/lease-example branch from 2680d32 to c87365b Compare May 16, 2020 08:18
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 <[email protected]>
Co-authored-by: Rossen Stoyanchev <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
@OlegDokuka OlegDokuka requested a review from rstoyanchev May 18, 2020 12:43
Co-authored-by: Rossen Stoyanchev <[email protected]>
Signed-off-by: Oleh Dokuka <[email protected]>
@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