Global

Members

changeEventName

Constant for event name to avoid strings everywhere

Source:

RecipesClient

The client object for recipes

Source:

Methods

generateClientId() → {string}

Generates a unique client id;

Source:
Returns:
  • The unique client id
Type
string

getClientNodePrefix(clientId, prefixopt) → {string}

Generates the client node prefix for the given client id and (optional) prefix

Parameters:
Name Type Attributes Description
clientId string

The client id

prefix string <optional>

The optional prefix

Source:
Returns:
Type
string

leaderSelector(clientNodePrefix) → {function}

Returns a function that returns true iff the first of the supplied nodes matches the prefix, i.e. if the client with that prefix is in the "leader" position.

Parameters:
Name Type Description
clientNodePrefix string

The client node prefix

Source:
Returns:
Type
function

makeRetryable(obs$, delay$, retryPredicateopt) → {Observable}

Makes an observable retryable with the provided delays.

Parameters:
Name Type Attributes Description
obs$ Observable

The input observable

delay$ Observable

The delays to use

retryPredicate function <optional>

Determines if the retry should occur based on the supplied error object. If not supplied, all errors are retried.

Source:
Returns:
Type
Observable

observeClientState(clientFactory) → {Observable}

Creates an observable of client state using the given client factory. when subscribed to, this creates a new client and connects to it. The observable elements are { client, connected, readonly } and reflect the current state of the client. Throws an error in the event of a nonrecoverable state.

Parameters:
Name Type Description
clientFactory function

Function that returns a node-zookeeper-client instance

Source:
Returns:
Type
Observable

observeCreateNode(options)

Creates an observable that emits true when a node has been removed

Parameters:
Name Type Description
options Object
Properties
Name Type Description
client ZookeeperClient

The node-zookeeper-client instance

path string

The path of the node to remove

mode CreateMode

Whether to watch the node and returns a promise/observable for the

Source:

observeDelay(options) → {Observable}

Creates an observable of delay values for retries given the provided retry options

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
initialDelay number <optional>
500

The initial retry delay

delayFactor number <optional>
2

The factor by which to increase each delay

maxDelay number <optional>
8000

The max delay value

maxRetries number <optional>
7

The max number of retries

Source:
Returns:
Type
Observable

observeExclusiveLock(options)

Generates an observable for an exclusive lock on a resource.

Parameters:
Name Type Description
options Object
Properties
Name Type Description
client Object

The node-zookeeper-client instance

path Object

The path on which to get the lock

clientNodePrefix string

The client node prefix for this action

Source:

observeLeaderState(options)

Attempts to acquire a lock and the given path and observes the lock state

Parameters:
Name Type Description
options Object

The options

Properties
Name Type Attributes Description
clientState$ Observable

The client state observable

path string

The path at which to observe

watchSelector function

Function that is called back with

clientId string <optional>

The client id to use, one is allocated if not supplied

Source:

observeNodeChildren(client, options)

Creates an observable of the children of a node. The filter and sort functions are passed the node names of the children, without the parent path.

Parameters:
Name Type Description
client ZookeeperClient

The node-zookeeper-client instance

options Object
Properties
Name Type Attributes Description
path string

The path of the parent node

filter function <optional>

The filter function

sort function <optional>

The sort function

watcher function <optional>

The watcher function

Source:

observeNodeValue(options)

Creates an observable of a node

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
watch boolean <optional>
false

Whether to watch the node

accessor function

The function that accepts the callback handler and returns a promise/observable for the value we care about.

Source:

observeOneForAllAction(options)

Generates an observable for an all for one action

Parameters:
Name Type Description
options Object
Properties
Name Type Description
client Object

The node-zookeeper-client instance

path Object

The path on which to get the lock

clientNodePrefix string

The client node prefix for this action

action function
testActionDone function
Source:

observeRemoveNode(client, options)

Creates an observable that emits true when a node has been removed

Parameters:
Name Type Description
client ZookeeperClient

The node-zookeeper-client instance

options Object
Properties
Name Type Attributes Default Description
path string

The path of the node to remove

watch boolean <optional>
false

Whether to watch the node and returns a promise/observable for the

Source:

observeSeekClientNodeState(options)

Generates an observable for an exclusive lock on a resource.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
client string

The node-zookeeper-client instance

path string

The path on which to get the lock

clientNodePrefix string

The client node prefix for this action

select function <optional>

The client id for this action

repeat function

The client id for this action

Source:

observeSeekState(options)

A generic state seeking algorithm that takes the supplied observable and returns its state, optionally transformed, as the output. This repeats indefinitely after the wait observable completes on each cycle, so that observable should emit when the state should be reevaluated and issued by the main observable.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
state$ Observable
repeat function
select function <optional>
Source:

parseClientNode(node, sequential) → {Object}

Parses a client node name, i.e. the node name without the full path. Returns an object with a client property and, if appropriate, type and sequence properties.

Parameters:
Name Type Description
node string

The node name to parseClientNode

sequential boolean

Whether this node has a sequence number appended

Source:
Returns:
Type
Object

sortClientNodesBySequence() → {number}

Sorting function for nodes, sorts in ascending order of sequence number. Only applicable to sequential nodes.

Source:
Returns:
Type
number