Skip to content

inbetgames/excetera

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Excetera

Bindings for etcd's HTTP API.

Status

This is alpha-quality software. Everything described in the docs should work as advertised, but some edge-cases might still pop up.

One particular feature that is likely to malfunction is request timeouts. Any help testing those or pinpointing issues with them will be appreciated.

Usage

Add Excetera as a dependency to your project and modify the :etcd_url config parameter to point to the location of your etcd instance:

config :excetera, etcd_url: "http://my.host.name:4001/v2/keys"

Now you can fetch and set values:

Excetera.set!("/test/key", "value")

Excetera.fetch("/test/key")
#=> {:ok, "value}
Excetera.fetch!("/test/key")
#=> "value"

Excetera.delete!("/test/key")
Excetera.get("/test/key", "default")
#=> "default"

Apart from strings and values convertible to strings, Excetera supports some other types:

map = %{any: "elixir term", can: {'be', 'encoded'}}
Excetera.set!("/test/term", map, type: :term)
Excetera.fetch!("/test/term", type: :term)
#=> %{any: "elixir term", can: {'be', 'encoded'}}

json_map = %{json: ['is', 'lossy']}
Excetera.set!("/test/json", json_map, type: :json)
Excetera.fetch!("/test/json", type: :json)
#=> %{"json" => ['is', 'lossy']}

You can also wait for new changes to arrive:

spawn_link(fn ->
  IO.inspect Excetera.fetch!("/test/nokey", wait: true)
end)
Excetera.set!("/test/nokey", "hello")

# "hello" is printed to the console

Documentation

The source code in lib/excetera.ex contains inline documentation of the API.

About

Elixir bindings for etcd's HTTP API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages