nim_consul: simple Consul access from Nim
This library provides an SDK around the Consul (https://www.consul.io/) HTTP API. Currently it's extremely underdeveloped; it exposes a single element of the api, kvGet, which allows for the retrieval of elements from the Consul kv store.
Procs
proc newConsul(uri: string = nil): Consul {.
raises: [ValueError], tags: [].}-
Create a new Consul agent client. Accepts an optional argument uri, the URI at which to make agent requests. If no uri is provided, defaults to looking for an agent running on localhost at the default port.
Examples:
let consul = newConsul() doAssert "http://localhost:8500/" == consul.uri let customUri = "https://192.168.111.222:8761" consul2 = newConsul(customUri) doAssert consul2.uri == customUri
proc newAsyncConsul(uri: string = nil): AsyncConsul {.
raises: [ValueError], tags: [].}-
Create a new Consul agent client. Accepts an optional argument uri, the URI at which to make agent requests. If no uri is provided, defaults to looking for an agent running on localhost at the default port.
Uses AsyncHttpClient as the underlying HTTP client, so all API operations are async.
Examples:let consul = newAsyncConsul() doAssert "http://localhost:8500/" == consul.uri let customUri = "https://192.168.111.222:8761" consul2 = newAsyncConsul(customUri) doAssert consul2.uri == customUri
proc kvGet(consul: AsyncConsul; key: string; aclToken: string = nil): Future[KvResponse] {.
raises: [FutureError], tags: [RootEffect, TimeEffect, ReadIOEffect].}-
Retrieve a single element from the kv store. Accepts an optional aclToken argument if the kv has an ACL in place.
Currently only returns a single value, regardless of how many are returned by the API.
Examples:let consul = newConsul("http://192.168.111.222:8500") (idx, kvItems) = consul.kvGet("virgil/nj/staff_per_route")
proc kvGet(consul: Consul; key: string; aclToken: string = nil): KvResponse {.
raises: [ HttpRequestError, SslError, OSError, IOError, TimeoutError, ProtocolError, KeyError, Exception, OverflowError, ValueError, UnpackError, JsonParsingError], tags: [ReadIOEffect, WriteIOEffect, TimeEffect].}-
Retrieve a single element from the kv store. Accepts an optional aclToken argument if the kv has an ACL in place.
Currently only returns a single value, regardless of how many are returned by the API.
Examples:let consul = newConsul("http://192.168.111.222:8500") (idx, kvItems) = consul.kvGet("virgil/nj/staff_per_route")