etcd-1.0.3: 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 Source

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 Source

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

Types

data Node Source

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

_nodeKey :: !Key

The key of the node. It always starts with a slash character (0x47).

_nodeCreatedIndex :: !Index

A unique index, reflects the point in the etcd state machine at which the given key was created.

_nodeModifiedIndex :: !Index

Like _nodeCreatedIndex, but reflects when the node was laste changed.

_nodeDir :: !Bool

True if this node is a directory.

_nodeValue :: !(Maybe Value)

The value is only present on leaf nodes. If the node is a directory, then this field is Nothing.

_nodeNodes :: !(Maybe [Node])

If this node is a directory, then these are its children. The list may be empty.

_nodeTTL :: !(Maybe TTL)

If the node has TTL set, this is the number of seconds how long the node will exist.

_nodeExpiration :: !(Maybe UTCTime)

If TTL is set, then this is the time when it expires.

type Index = Int Source

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

type Key = Text Source

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

type Value = Text Source

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 Source

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) Source

Get the node at the given key.

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

Set the value at the given key.

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

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

Directory operations

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

Create a directory at the given key.

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

List all nodes within the given directory.

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

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 () Source

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