-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add kv txn get-or-empty operation. #14474
Conversation
cdcc6fa
to
d8f0131
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing job adding this small enhancement @hashi-derek 👏
Overall this is exactly what I imagined too when thinking about this problem.
I have a couple of minor nits inline which I don't think block merging this.
My biggest bit of feedback would be on the name chosen. I think get-if-exists
is slightly more clear/descriptive of the behaviour vs. get-not-exists
. I see how there is a consistency argument with check-not-exists
but I think that makes more sense in context "Check that key X does not exist" is naturally expressed by check-not-exists
whereas "Get the value of key X if it exists or empty otherwise" requires a double-negative to map to get-not-exists
and maps more naturally to get-if-exists
in my mind anyway 😄.
If you disagree though it'd not a mountain I feel the need to die on! Should be a quick enough update if you do!
d8f0131
to
35a4189
Compare
35a4189
to
50b3f7b
Compare
How about |
50b3f7b
to
8470655
Compare
@kisunji Yeah, I wasn't a fan of any of the names I had come up with. |
8470655
to
498582e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Description
Adds a
get-or-empty
operation to the kv txn api. There is currently no operation for fetching the value of a key that may not yet exist. The currentget
command will cause the entire transaction to roll-back if the key doesn't exist. The new op will return anil
value for a key if-not-found.https://www.consul.io/api-docs/txn#kv-operations
PR Checklist