Comments (5)
Hi 😄
I think the way to go is to first expose all of the available features Consul offers, with a Ruby centric API and then layer additional, more convenient APIs on top of that.
For python-consul, the approach I've taken is to return all the available JSON for calls that return JSON, and for X-Consul-Index, to return a tuple of (index, data) from all calls that support blocking reads.
e.g. kv.get returns:
(index, {
"CreateIndex": 100,
"ModifyIndex": 200,
"LockIndex": 200,
"Key": "foo",
"Flags": 0,
"Value": "bar",
"Session": "adf4238a-882b-9ddc-4a9d-5b6758e4159e"
})
Returning a tuple is pretty Pythonic. I'm not sure what a more Ruby centric way would be?
This is a little verbose. e.g.
index, data = c.kv.get('foo')
# make use of data['Value']
Isn't nearly as nice as:
foo = Diplomat.get('foo')
# => "bar"
if all you want is a KV store. But it does allow you to use all of Consul's features. Particularly long polling to dynamically listen for updates, and it makes ModifyIndex available for cas updates.
Once the API is in place to expose the raw Consul features, additional more convenient APIs like Diplomat's current API can be layered on top.
from diplomat.
How about this?
Get signature:
get(key, scope=:first, options={})
Input:
options[:index] = string
options[:wait] = string time component
Return
options[:index] is modified on return to be the returned index.
This keeps get happy, doesn't change too much code, gives access to all values over time. The options seems to be the ruby-ish standard way to pass in info and deal with expansion. We could move in scope, but that would break existing things.
If you don't like the writing into an input focused structure, we could add a meta hash to return the requests meta data. Put index, last-contact, ...
I working on this now. I don't really care which I just need long polling. :-)
from diplomat.
@galthaus looks nice 👍
Looking forward to seeing that PR!
from diplomat.
Solved thanks to #11
from diplomat.
Released in version 0.2.2: https://rubygems.org/gems/diplomat/versions/0.2.2
from diplomat.
Related Issues (20)
- /v1/catalog/register is broken after upgrade to v2.1.2 HOT 1
- Support Consul 1.4.0+ ACL system HOT 2
- Add support for Consul 1.5.x ACL tokens HOT 2
- Add support for Consul 1.5.x Auth Method and Binding Rule HTTP APIs HOT 2
- Improve error message in case of missing ACL
- 2.3.0: syntax error in file lib/diplomat/rest_client.rb:243 ? HOT 4
- It is unable to retrieve service configuration from consul HOT 2
- Add support for Operator Autopilot API HOT 5
- Due to faraday 1.1 release diplomat only works on ruby 2.4+
- Unable to use multiple tags when querying for services HOT 2
- Bump faraday requirement HOT 1
- Register HTTP checks HOT 3
- Add support for default datacenter HOT 3
- Broken link to API documentation HOT 3
- Register entities via agent
- Add blocking read support for service health endpoint HOT 3
- Faraday 2.0.0 breaks diplomat HOT 4
- Faraday 1.x can bypass Diplomat::QueryAlreadyExists HOT 1
- Can't get it to work with auth token given in config HOT 5
- Kv.put() method with Consul v1.10.1 results in KV entries that are visible via CLI/API, but not UI HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diplomat.