Package

com.eiipii.etcd

client

Permalink

package client

An easy-to-configure, asynchronous etcd client with key-value methods, support for authentication and methods for retrieving statistics from etcd clusters.

EtcdClient is built on top of Scala Futures and Promises, AsyncHttpClient, Netty and JSON4S.

It is implemented according to version 2 of the Etcd API.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. client
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class EtcdClient extends AnyRef

    Permalink

    Asynchronously sends HTTP requests to etcd servers and handles outcome responses.

    Asynchronously sends HTTP requests to etcd servers and handles outcome responses.

    EtcdClient

    EtcdClient uses AsyncHttpClient in order to build and send HTTP requests. Its methods were developed to suit the etcd documentation. All methods use Scala Futures and Promises in order to provide an asynchronous implementation.

    Depending on the request, either an error will be thrown or a response will be returned. In both cases, there is a case class extending a trait in package model with a name ending in Result, which will be returned containing either the response or information about the error.

    For example, when performing an EtcdClient.setKey operation, an EtcdSetKeyResult is expected. The outcome of the operation, either an error or a response, can be accessed considering both cases. An easy way to retrieve a response could be with a match statement:

    etcdcli.setKey(key, value) onSuccess  {
    case EtcdSetKeyResponse(headers, body) =>
     ???
    }
    Key-Value Methods

    The implementation of key-value methods follows the specification given in the etcd Client API. Their purpose is to set, retrieve, modify or delete keys, values and directories in etcd. It is also possible to wait (set a watch) on etcd keys, so as to monitor changes in the server in real time and conditionally set operations depending on the response obtained once a change in the data is registered.

    Key-Value methods take as inputs case classes defined in package model. The recommended way of getting input data (EtcdKeys, EtcdDirectorys, hidden nodes and EtcdValues) for key-value methods is using the EtcdModel object.

    Statistics

    The implementation of methods for retrieving etcd cluster statistics also follows the specification given in the etcd Client API and etcd Admin API.

    Authentication Methods

    The implementation of authentication methods follows the specification given in the etcd authentication and security API. With the help of these methods, a system administrator can enable authentication and create users and roles with different levels of access to etcd. etcd only allows authentication on authentication methods and key-value methods.

    Member Methods

    The implementation for member methods follows the specification given in the etcd Members API. They allow an administrator to configure a cluster, by changing the members of a cluster.

  2. case class EtcdConfiguration(conn: String, authorization: Option[EtcdUserAuthenticationData] = None, optContext: Option[SslContext] = None) extends Product with Serializable

    Permalink

    Configures the EtcdClient with information about an endpoint to which requests will be sent and optional authorization data.

    Configures the EtcdClient with information about an endpoint to which requests will be sent and optional authorization data.

    conn

    String representing an HTTP endpoint composed of an IP address and a port.

    authorization

    Optional EtcdUserAuthenticationData that will be used for authorization.

Value Members

  1. object EtcdClient

    Permalink

    EtcdClient companion object.

  2. object EtcdDSL

    Permalink

    Domain specific language with methods for the configuration of an etcd client.

  3. package handlers

    Permalink

    AsyncHttpClient handlers used to handle requests and return etcd responses asynchronously.

    Handlers

    AsyncHttpClient handlers used to handle requests and return etcd responses asynchronously.

    For a given HTTP request, etcd most often returns a response containing a JSON array in its body (although, sometimes it may return an empty body). A response may also contain HTTP headers with the HTTP status code for the response and some information of the etcd cluster (mostly indexes captured as instances of EtcdIndex). AsyncHttpClient offers support for handling HTTP requests with customized handlers. Each handler formats a type of response returned by etcd by parsing the JSON array returned in the response and retrieving the pertinent information in the response's headers. The parsing is done using JSON4S extract method and case classes defined in package model. The information retrieved from the response's headers is passed along with the body to appropriate case classes in the same package.

    Http requests to etcd may return and error response or a success response. Error responses usually contain useful information on what went wrong, while success responses return the status of etcd after the request is performed. Handlers appropriately adapted to deal with both situations.

  4. package model

    Permalink

    Contains case classes for dealing with etcd HTTP responses and building correct HTTP requests to etcd.

    Model

    Contains case classes for dealing with etcd HTTP responses and building correct HTTP requests to etcd. Most of the case classes are self-explanatory, once the Responses and Errors section below is read. Those that are not are discussed in more detail in this documentation. They are mostly used by handlers or by the client to extract information from JSON objects or write information to JSON objects sent in requests.

    Also, package model contains an object for properly building instances of EtcdKey, EtcdDirectory, hidden nodes and EtcdValue.

    Finally, it contains JSON4S custom serializers for JSON parsing support. All the custom serializers contained in this package are contained in the EtcdJsonFormat object, which in turn is used by handlers in package handlers to parse responses from etcd to HTTP requests.

    Responses and Errors

    All requests can return either a response or an error. In order to deal with this two possible situations, the outcome of each request is represented by a Result sealed trait in this package. These traits are extended by case classes representing an error or a response in the manner described bellow. The naming convention for Result sealed traits is the following: Etcd<NameOfTheEtcdClientMethod>Result. For example EtcdGetKeyResult.

    There are two types of error that etcd could return. For EtcdClient, they are represented in the EtcdStandardError and EtcdRequestError. One of these case classes extends each Result sealed trait representing the outcome of a request sent by the client.

    On the other hand, Responses are dealt with using Response case classes. They contain all the necessary fields used to deserialize the information contained in the HTTP response received from etcd. Response case classes also extend Result sealed traits. The naming convention is similar: Etcd<NameOfTheEtcdClientMethod>Response. For example EtcdGetKeyResponse.

    Both Response and Error case classes contain the relevant information about etcd that can be found in headers and in the response body.

    A more involved case, which is delt with a callback, is EtcdWaitForKeyResult.

Inherited from AnyRef

Inherited from Any

Ungrouped