Reference¶
-
class
cyclotron_consul.kv.
Adapter
(sink, api)¶ -
property
api
¶ Alias for field number 1
-
property
sink
¶ Alias for field number 0
-
property
-
class
cyclotron_consul.kv.
Api
(read_key, watch_key)¶ -
property
read_key
¶ Alias for field number 0
-
property
watch_key
¶ Alias for field number 1
-
property
-
class
cyclotron_consul.kv.
KeyValue
(key, value)¶ -
property
key
¶ Alias for field number 0
-
property
value
¶ Alias for field number 1
-
property
-
cyclotron_consul.kv.
adapter
(source)¶ Creates a consul adapter for the KV API.
- Parameters
source – an aiohttp response stream.
- Returns
A Client object
-
cyclotron_consul.kv.
read_key
(http_client, endpoint, key)¶ Reads a key on the specified endpoint
- Parameters
http_client – An instance of http client. This parameter is already binded when called from the adapter.
endpoint – the consul server full url
key – The key to read
- Returns
On observable that emits a single KeyValue item if the request succeeds. Otherwise the observable completes on error.
Example
>>>import cyclotron_consul.kv as kv >>>client = kv.client(http_source) >>>client.api.read_key(“http://localhost:8500”, “mykey”).subscribe( >>> on_next=print >>>) >>># forward client.sink to http driver sink
-
cyclotron_consul.kv.
watch_key
(http_client, endpoint, key)¶ Reads a key on the specified endpoint, and watch for updates.
- Parameters
http_client – An instance of http client. This parameter is already binded when called from the adapter.
endpoint – the consul server full url
key – The key to read
- Returns
On observable that emits a KeyValue item each time the value associated to the key is updated on consul. In case of error, the observable completes on error.
Example
>>>import cyclotron_consul.kv as kv >>>client = kv.client(http_source) >>>client.api.watch_key(“http://localhost:8500”, “mykey”).subscribe( >>> on_next=print >>>) >>># forward client.sink to http driver sink