etcd-1.0.5: Client for etcd, a highly-available key value store

Safe HaskellNone
LanguageHaskell2010

Network.Etcd

Contents

Description

This module contains an implementation of the etcd client.

Synopsis

Documentation

data Client #

The Client holds all data required to make requests to the etcd cluster. You should use createClient to initialize a new client.

createClient :: [Text] -> IO Client #

Create a new client and initialize it with a list of seed machines. The list must be non-empty.

Types

data Node #

The Node corresponds to the node object as returned by the etcd API.

There are two types of nodes in etcd. One is a leaf node which holds a value, the other is a directory node which holds zero or more child nodes. A directory node can not hold a value, the two types are exclusive.

On the wire, the two are not really distinguished, except that the JSON objects have different fields.

A node may be set to expire after a number of seconds. This is indicated by the two fields ttl and expiration.

Constructors

Node 

Fields

Instances

Eq Node # 

Methods

(==) :: Node -> Node -> Bool #

(/=) :: Node -> Node -> Bool #

Ord Node # 

Methods

compare :: Node -> Node -> Ordering #

(<) :: Node -> Node -> Bool #

(<=) :: Node -> Node -> Bool #

(>) :: Node -> Node -> Bool #

(>=) :: Node -> Node -> Bool #

max :: Node -> Node -> Node #

min :: Node -> Node -> Node #

Show Node # 

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

FromJSON Node # 

type Index = Int #

The etcd index is a unique, monotonically-incrementing integer created for each change to etcd. See etcd documentation for more details.

type Key = Text #

Keys are strings, formatted like filesystem paths (ie. slash-delimited list of path components).

type Value = Text #

Values attached to leaf nodes are strings. If you want to store structured data in the values, you'll need to encode it into a string.

type TTL = Int #

TTL is specified in seconds. The server accepts negative values, but they don't make much sense.

Low-level key operations

get :: Client -> Key -> IO (Maybe Node) #

Get the node at the given key.

set :: Client -> Key -> Value -> Maybe TTL -> IO (Maybe Node) #

Set the value at the given key.

create :: Client -> Key -> Value -> Maybe TTL -> IO Node #

Create a value in the given key. The key must be a directory.

wait :: Client -> Key -> IO (Maybe Node) #

Wait for changes on the node at the given key.

waitIndex :: Client -> Key -> Index -> IO (Maybe Node) #

Same as wait but at a given index.

waitRecursive :: Client -> Key -> IO (Maybe Node) #

Same as wait but includes changes on children.

waitIndexRecursive :: Client -> Key -> Index -> IO (Maybe Node) #

Same as waitIndex but includes changes on children.

Directory operations

createDirectory :: Client -> Key -> Maybe TTL -> IO () #

Create a directory at the given key.

listDirectoryContents :: Client -> Key -> IO [Node] #

List all nodes within the given directory.

listDirectoryContentsRecursive :: Client -> Key -> IO [Node] #

Same as listDirectoryContents but includes all descendant nodes. Note that directory Nodes will not contain their children.

removeDirectory :: Client -> Key -> IO () #

Remove the directory at the given key. The directory MUST be empty, otherwise the removal fails. If you don't care about the keys within, you can use removeDirectoryRecursive.

removeDirectoryRecursive :: Client -> Key -> IO () #

Remove the directory at the given key, including all its children.