Xline
Xline copied to clipboard
[Refactor]: Add a session structure to renew lock lease automatically
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
- [X] I agree to follow this project's Code of Conduct
@Phoenix500526 would like to take on this issue
Are you interested in this issue? @rohansx
@Phoenix500526 yeah sure!
Oh, sorry for the delay reply. Thank you for your contribution. @rohansx
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.