Module etcd-client.client.pool

Pool of clients for etcd.

Instance methods

instance.request (self, location, req) Send the request to a client.
instance.stream (self, location) Create a stream to a client.
instance.close (self) Close a client pool.
instance.add (self, clients) Add clients to the pool.
instance.remove (self, clients) Remove clients from the pool.
new (clients) Create a new pool client instance.


Instance methods

instance.request (self, location, req)

Send the request to a client.

In the pool implementation it switches to a next client if the request failed with a transient error (as example, server is unavailable).

Parameters:

  • self

    Pool instance.

  • location (string)

    A target location.

  • req (string)

    Request body.

Returns:

  1. true, response
  2. false, etcd-client.error.http.HttpError or etcd-client.error.etcd.EtcdError.
instance.stream (self, location)

Create a stream to a client.

In the pool implementation it switches to a next client if the request failed with a transient error (as example, server is unavailable).

Parameters:

  • self

    Pool instance.

  • location (string)

    A target location.

Returns:

  1. true, etcd-client.client.jsstream instance
  2. false, etcd-client.error.http.HttpError.
  3. false, etcd-client.error.etcd.EtcdError.
instance.close (self)

Close a client pool.

Parameters:

  • self

    Pool instance.

Returns:

    nil
instance.add (self, clients)

Add clients to the pool.

Parameters:

  • self

    Pool instance.

  • clients

    An array of clients. Each client must implement the pool instance interface: instance.request

Returns:

    nil
instance.remove (self, clients)

Remove clients from the pool.

Parameters:

  • self

    Pool instance.

  • clients

    An array of clients.

Returns:

    nil

    Note that clients needs to be closed by the caller.

new (clients)

Create a new pool client instance.

Parameters:

  • clients (table)

    An array of clients. Each client must implement the pool instance interface: instance.request

Returns:

    a pool instance.