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

[Refactor]: Add a session structure to renew lock lease automatically #684

Closed
1 task done
Phoenix500526 opened this issue Mar 8, 2024 · 5 comments · Fixed by #820
Closed
1 task done

[Refactor]: Add a session structure to renew lock lease automatically #684

Phoenix500526 opened this issue Mar 8, 2024 · 5 comments · Fixed by #820
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Phoenix500526
Copy link
Collaborator

Description about the feature

At present, we are addressing issue #664 in PR #666. However, the current implementation is not very user-friendly, as users of the lock feature need to renew the lock lease manually.

For example,

    // omit some code ...
    // grant a lease id
    let lease_resp = lease_client
        .grant(LeaseGrantRequest::new(DEFAULT_SESSION_TTL))
        .await?;
    let lock_lease_id = lease_resp.id;
    // do the lock operation
    let req = build_request(matches).with_lease(lock_lease_id);
    let lock_resp = client.lock_client().lock(req).await?;
    lock_resp.print();
    // renew the lock lease manually.
    let (keeper, stream) = client
        .lease_client()
        .keep_alive(LeaseKeepAliveRequest::new(lock_lease_id))
        .await?;

In fact, a better approach to achieve the same result is to have the lock method return a data structure, such as session or lock_scope. Within the lock method, a LockClient will grant a lease ID and store it in the session. This session will automatically renew the lease ID until it is dropped.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rohansx
Copy link

rohansx commented Mar 13, 2024

@Phoenix500526 would like to take on this issue

@Phoenix500526
Copy link
Collaborator Author

Are you interested in this issue? @rohansx

@rohansx
Copy link

rohansx commented Mar 17, 2024

@Phoenix500526 yeah sure!

@Phoenix500526
Copy link
Collaborator Author

Oh, sorry for the delay reply. Thank you for your contribution. @rohansx

@Phoenix500526 Phoenix500526 linked a pull request May 15, 2024 that will close this issue
@Phoenix500526
Copy link
Collaborator Author

Hi, @rohansx ! Due to the release plan, this issue will be closed after pr #820 is merged. Sorry about that. If you haven't started working on this issue yet, could you please consider picking up another one? We have other good-first-issues available. If you're interested, please feel free to claim one of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants