Ecwid / consul-api

Java client for Consul HTTP API
Apache License 2.0
417 stars 175 forks source link

NewSession.setLockDelay() has no effect #161

Closed chrismiller closed 6 years ago

chrismiller commented 6 years ago

Currently NewSession.setLockDelay() takes a long parameter. This gets serialised to JSON as a number (rather than a string of the form "15s", as per https://www.consul.io/api/session.html). The net result is Consul ignores the lock-delay parameter that is passed through and it is not possible to set a lock-delay for the session.

vgv commented 6 years ago

Hi @chrismiller

I've tested this on the latest consul 1.0.7 and long LockDelay parameter works just fine. Consul internally accepts both string '90s' and just number 90 (for example).

So, these expressions are equals:

NewSession session = new NewSession();
session.setName("bugaga");
session.setLockDelay(90);  // current code
NewSession session = new NewSession();
session.setName("bugaga");
session.setLockDelay("90s"); // in my temporary local long->String replacement

Could you please check it? If you still experience the problems with LockDelay, could you please provide code example?

chrismiller commented 6 years ago

Ah OK thanks @vgv. Looks like the problem was a misunderstanding on my part of how the lock-delay feature in Consul works and so my own tests were flawed (I hadn't appreciated it only kicks in if the session is invalidated by Consul due to timeout etc). Sorry for the trouble, I'm happy to close this request.