Coder Social home page Coder Social logo

consul-lisp's Introduction

Consul

This is a library to support HashiCorp's Consul. At this stage, only getting/putting/deleting KV values is supported, but full support for service discovery is in the works.

Configuration and use of the library is extremely simple. You'll need to create a consul object (which holds the information about a given consul server), then make kv-get, kv-put, and kv-delete calls to get, set, and delete values. When instantiating the consul object, it assumes sane defaults if you don't supply any parameters. Specifically, if instantiated with no parameters, it assumes no TLS, a host of "localhost", a port of 8500, and a protocol version "1". There is a field for an authentication token, but this is unused in this version of code (will be supported in future versions).

CL-USER> (defvar *consul* (make-instance 'consul:consul :host "consul.example.com" :tls nil))
*CONSUL*
CL-USER>

Once the consul object has been created, it can be used to get, set, and delete consul KV values:

CL-USER> (consul:kv-get *consul* "electric_boogaloo")
NIL
NIL
CL-USER> (consul:kv-put *consul* "electric_boogaloo" "Test data.")
T
CL-USER> (consul:kv-get *consul* "electric_boogaloo")
"Test data."
6422
CL-USER> (consul:kv-delete *consul* "electric_boogaloo")
T
CL-USER> (consul:kv-get *consul* "electric_boogaloo")
NIL
NIL
CL-USER> 

You can also ask for a recursive result. Recursive results are returned as a list of conses of key:value pairs (note that this can be a very expensive operation in time, client memory, and server resources if the values are large - use with extreme caution):

CL-USER> (consul:kv-put *consul* "foo" "test value 1")
T
CL-USER> (consul:kv-put *consul* "bar" "test value 2")
T
CL-USER> (consul:kv-put *consul* "baz" "test value 3")
T
CL-USER> (consul:kv-get *consul* "/" :recurse t)
(("bar" . "test value 2") ("baz" . "test value 3") ("foo" . "test value 1"))
CL-USER> 

Finally, you can ask for just a list of keys:

(consul:kv-get *consul* "/" :keys t)
("bar" "baz" "foo")
CL-USER> 

That's it at this point. Future features will include support for services, health checks, and watchers for KV variables with callbacks of arbitrary functions.

ToDo

  • Support for KV value watchers (with callbacks)
  • Support cas for puts
  • Support cas for deletes
  • Support flags for gets
  • Support flags for puts
  • Support acquire for puts
  • Support release for puts
  • Support recurse for delete
  • Support for Services
  • Support for Health Checks
  • Support for tokens
  • Support for KV Transactions

consul-lisp's People

Contributors

jfrancis42 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.