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

Release and delete a lock as one operation #840

Closed
fraenkel opened this issue Apr 4, 2015 · 6 comments
Closed

Release and delete a lock as one operation #840

fraenkel opened this issue Apr 4, 2015 · 6 comments
Labels
type/enhancement Proposed improvement or new feature

Comments

@fraenkel
Copy link

fraenkel commented Apr 4, 2015

The current behavior follows what I consider the default behavior for a session to release a lock. With the addition of being able to specify delete, wouldn't it also be useful to allow the Release() API to optionally delete as well? We have cases where we would prefer to avoid the Release/Destroy 2 step and just be able to combine them as one.

I could easily imagine that the DELETE of an acquired KV could also allow the flag & release parameters.

@armon armon added the type/enhancement Proposed improvement or new feature label Apr 6, 2015
@armon
Copy link
Member

armon commented Apr 6, 2015

Tagged as enhancement, makes sense to me!

@slackpad
Copy link
Contributor

This is now supported in Consul 0.7 - https://www.consul.io/docs/agent/http/kv.html#txn.

@fraenkel
Copy link
Author

@slackpad May I ask how txn solves this? You can only do PUTs in a txn, so how do I combine a PUT (to unlock) and DELETE?

@slackpad
Copy link
Contributor

@fraenkel with the /v1/txn endpoint you PUT a JSON structure with a list of operations to perform - you would PUT a structure like this:

[
  {
    "KV": {
      "Verb": "unlock",
      "Key": "<key>",
      "Session": "<session id>"
    }
  },
  {
    "KV": {
      "Verb": "delete",
      "Key": "<key>"
    }
  }
]

These are done atomically, so if the unlock succeeds it will delete the key as part of the same request.

@fraenkel
Copy link
Author

fraenkel commented Sep 21, 2016

@slackpad The docs say PUT is only supported which is why I asked. Ah, so that meant you PUT /v1/txn but any verb is supported.

@slackpad
Copy link
Contributor

That's correct - you always PUT to /v1/txn with a list of updates and their associated verbs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Proposed improvement or new feature
Projects
None yet
Development

No branches or pull requests

3 participants