Add Client.ReleaseByToken for cross-process lock release - #95
Open
Yusufihsangorgel wants to merge 1 commit into
Open
Add Client.ReleaseByToken for cross-process lock release#95Yusufihsangorgel wants to merge 1 commit into
Yusufihsangorgel wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #81.
Lock.Release needs the *Lock that Obtain returned — its fields are unexported, so
a different process that only persisted the token has no way to construct one.
The workaround is re-Obtain-ing with the same token, which reopens the split-second
unlocked window this issue is about.
Adds Client.ReleaseByToken / ReleaseMultiByToken, backed by a new release_token.lua
that does the same atomic getrange-prefix check obtain.lua already uses for
token-based re-acquisition (canOverrideKeys), instead of the full token+metadata
value release.lua requires. So the caller only needs the key and token — same
inputs as Options.Token.
Named it ReleaseByToken rather than Release since Lock embeds *Client — a
same-named Client.Release would be legal Go but would sit shadowed behind Lock's
own Release(ctx), which seemed worth just avoiding.
Doesn't touch any FenceKey counter, matching Lock.Release's existing behaviour
(per #94, the fence counter is meant to keep advancing regardless of release path).
Tests: TestClient_ReleaseByToken, TestClient_ReleaseByToken_with_metadata,
TestClient_ReleaseByToken_wrong_token, TestClient_ReleaseByToken_not_held.