Open etki opened 8 years ago
For what it's worth, I was able to find a workaround by using RawConsulClient
directly.
public void deleteKey(final String key, final long checkAndSetIndex) {
consulRawClient.makeDeleteRequest(
"/v1/kv/" + key,
(UrlParameters) () -> Collections.singletonList("cas=" + checkAndSetIndex)
);
}
Take a look at ConsulRawClient.java
to see how to construct one.
The problem is that all the different overloaded methods of deleteKVValue()
return Response<Void>
. In order to indicate whether the delete succeeded or not, we would need to return Response<Boolean>
. I see a few ways forward:
cas
parameter, but don't return the boolean. If callers want to know whether their delete succeeded, they'll have to do a KV get.deleteKVValue()
methods that support the cas
parameter and return Response<Boolean>
, but leave the others as-is. So deleteKVValue()
would return a mix of Response<Void>
and Response<Boolean>
depending on use case.Response<Boolean>
. Leave the old ones in place and @Deprecate
them.Response<Boolean>
, probably after a major version number change.@vgv Do you have a preference for the fix?
Consul (at least of version 0.6) returns boolean value for delete operation that marks it's success (normal deletion) or failure (e.g.
cas
parameter set to invalid value). It would be quite cool to add same support (ability to passcas
parameter and return boolean value) for client implementation.