Class: ConsulClient

vertx-consul-js/consul_client~ ConsulClient

new ConsulClient()

A Vert.x service used to interact with Consul.
Source:

Methods

agentInfo(resultHandler) → {ConsulClient}

Returns the configuration and member information of the local agent
Parameters:
Name Type Description
resultHandler function will be provided with the configuration and member information of the local agent
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogDatacenters(resultHandler) → {ConsulClient}

Return all the datacenters that are known by the Consul server
Parameters:
Name Type Description
resultHandler function will be provided with list of datacenters
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogNodes(resultHandler) → {ConsulClient}

Returns the nodes registered in a datacenter
Parameters:
Name Type Description
resultHandler function will be provided with list of nodes
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogNodeServices(node, resultHandler) → {ConsulClient}

Returns the node's registered services
Parameters:
Name Type Description
node string node name
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogNodeServicesWithOptions(node, options, resultHandler) → {ConsulClient}

Returns the node's registered services This is blocking query unlike ConsulClient#catalogNodeServices
Parameters:
Name Type Description
node string node name
options Object the blocking options
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogNodesWithOptions(options, resultHandler) → {ConsulClient}

Returns the nodes registered in a datacenter
Parameters:
Name Type Description
options Object options used to request nodes
resultHandler function will be provided with list of nodes
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogServiceNodes(service, resultHandler) → {ConsulClient}

Returns the nodes providing a service
Parameters:
Name Type Description
service string name of service
resultHandler function will be provided with list of nodes providing given service
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogServiceNodesWithOptions(service, options, resultHandler) → {ConsulClient}

Returns the nodes providing a service
Parameters:
Name Type Description
service string name of service
options Object options used to request services
resultHandler function will be provided with list of nodes providing given service
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogServices(resultHandler) → {ConsulClient}

Returns the services registered in a datacenter
Parameters:
Name Type Description
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

catalogServicesWithOptions(options, resultHandler) → {ConsulClient}

Returns the services registered in a datacenter This is blocking query unlike ConsulClient#catalogServices
Parameters:
Name Type Description
options Object the blocking options
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

cloneAclToken(id, idHandler) → {ConsulClient}

Clone Acl token
Parameters:
Name Type Description
id string the ID of token to be cloned
idHandler function will be provided with ID of cloned token
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

close()

Close the client and release its resources
Source:

coordinateDatacenters(resultHandler) → {ConsulClient}

Returns the WAN network coordinates for all Consul servers, organized by DCs
Parameters:
Name Type Description
resultHandler function will be provided with network coordinates for all Consul servers
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

coordinateNodes(resultHandler) → {ConsulClient}

Returns the LAN network coordinates for all nodes in a given DC
Parameters:
Name Type Description
resultHandler function will be provided with network coordinates of nodes in datacenter
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

coordinateNodesWithOptions(options, resultHandler) → {ConsulClient}

Returns the LAN network coordinates for all nodes in a given DC This is blocking query unlike ConsulClient#coordinateNodes
Parameters:
Name Type Description
options Object the blocking options
resultHandler function will be provided with network coordinates of nodes in datacenter
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

createAclToken(token, idHandler) → {ConsulClient}

Create new Acl token
Parameters:
Name Type Description
token Object properties of the token
idHandler function will be provided with ID of created token
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

createSession(idHandler) → {ConsulClient}

Initialize a new session
Parameters:
Name Type Description
idHandler function will be provided with ID of new session
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

createSessionWithOptions(options, idHandler) → {ConsulClient}

Initialize a new session
Parameters:
Name Type Description
options Object options used to create session
idHandler function will be provided with ID of new session
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

deleteValue(key, resultHandler) → {ConsulClient}

Remove the key/value pair that corresponding to the specified key
Parameters:
Name Type Description
key string the key
resultHandler function will be called on complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

deleteValues(keyPrefix, resultHandler) → {ConsulClient}

Removes all the key/value pair that corresponding to the specified key prefix
Parameters:
Name Type Description
keyPrefix string the prefix
resultHandler function will be called on complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

deregisterCheck(checkId, resultHandler) → {ConsulClient}

Remove a check from the local agent. The agent will take care of deregistering the check from the Catalog.
Parameters:
Name Type Description
checkId string the ID of check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

deregisterService(id, resultHandler) → {ConsulClient}

Remove a service from the local agent. The agent will take care of deregistering the service with the Catalog. If there is an associated check, that is also deregistered.
Parameters:
Name Type Description
id string the ID of service
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

destroyAclToken(id, resultHandler) → {ConsulClient}

Destroy Acl token
Parameters:
Name Type Description
id string the ID of token
resultHandler function will be called on complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

destroySession(id, resultHandler) → {ConsulClient}

Destroys the given session
Parameters:
Name Type Description
id string the ID of session
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

failCheck(checkId, resultHandler) → {ConsulClient}

Set status of the check to "critical". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

failCheckWithNote(checkId, note, resultHandler) → {ConsulClient}

Set status of the check to "critical". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
note string a human-readable message with the status of the check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

fireEvent(name, resultHandler) → {ConsulClient}

Fires a new user event
Parameters:
Name Type Description
name string name of event
resultHandler function will be provided with properties of event
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

fireEventWithOptions(name, options, resultHandler) → {ConsulClient}

Fires a new user event
Parameters:
Name Type Description
name string name of event
options Object options used to create event
resultHandler function will be provided with properties of event
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

getValue(key, resultHandler) → {ConsulClient}

Returns key/value pair that corresponding to the specified key
Parameters:
Name Type Description
key string the key
resultHandler function will be provided with key/value pair
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

getValues(keyPrefix, resultHandler) → {ConsulClient}

Returns the list of key/value pairs that corresponding to the specified key prefix.
Parameters:
Name Type Description
keyPrefix string the prefix
resultHandler function will be provided with list of key/value pairs
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

getValuesWithOptions(keyPrefix, options, resultHandler) → {ConsulClient}

Returns the list of key/value pairs that corresponding to the specified key prefix. This is blocking query unlike ConsulClient#getValues
Parameters:
Name Type Description
keyPrefix string the prefix
options Object the blocking options
resultHandler function will be provided with list of key/value pairs
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

getValueWithOptions(key, options, resultHandler) → {ConsulClient}

Returns key/value pair that corresponding to the specified key. This is blocking query unlike ConsulClient#getValue
Parameters:
Name Type Description
key string the key
options Object the blocking options
resultHandler function will be provided with key/value pair
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthChecks(service, resultHandler) → {ConsulClient}

Returns the checks associated with the service
Parameters:
Name Type Description
service string the service name
resultHandler function will be provided with list of checks
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthChecksWithOptions(service, options, resultHandler) → {ConsulClient}

Returns the checks associated with the service
Parameters:
Name Type Description
service string the service name
options Object options used to request checks
resultHandler function will be provided with list of checks
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthServiceNodes(service, passing, resultHandler) → {ConsulClient}

Returns the nodes providing the service. This endpoint is very similar to the ConsulClient#catalogServiceNodes endpoint; however, this endpoint automatically returns the status of the associated health check as well as any system level health checks.
Parameters:
Name Type Description
service string the service name
passing boolean if true, filter results to only nodes with all checks in the passing state
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthServiceNodesWithOptions(service, passing, options, resultHandler) → {ConsulClient}

Returns the nodes providing the service. This endpoint is very similar to the ConsulClient#catalogServiceNodesWithOptions endpoint; however, this endpoint automatically returns the status of the associated health check as well as any system level health checks.
Parameters:
Name Type Description
service string the service name
passing boolean if true, filter results to only nodes with all checks in the passing state
options Object options used to request services
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthState(checkStatus, resultHandler) → {ConsulClient}

Returns the checks in the specified status
Parameters:
Name Type Description
checkStatus Object the check status
resultHandler function will be provided with list of checks
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

healthStateWithOptions(checkStatus, options, resultHandler) → {ConsulClient}

Returns the checks in the specified status
Parameters:
Name Type Description
checkStatus Object the check status
options Object options used to request checks
resultHandler function will be provided with list of checks
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

infoAclToken(id, tokenHandler) → {ConsulClient}

Get info of Acl token
Parameters:
Name Type Description
id string the ID of token
tokenHandler function will be provided with token
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

infoSession(id, resultHandler) → {ConsulClient}

Returns the requested session information
Parameters:
Name Type Description
id string the ID of requested session
resultHandler function will be provided with info of requested session
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

infoSessionWithOptions(id, options, resultHandler) → {ConsulClient}

Returns the requested session information This is blocking query unlike ConsulClient#infoSession
Parameters:
Name Type Description
id string the ID of requested session
options Object the blocking options
resultHandler function will be provided with info of requested session
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

leaderStatus(resultHandler) → {ConsulClient}

Get the Raft leader for the datacenter in which the agent is running. It returns an address in format "10.1.10.12:8300"
Parameters:
Name Type Description
resultHandler function will be provided with address of cluster leader
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listAclTokens(resultHandler) → {ConsulClient}

Get list of Acl token
Parameters:
Name Type Description
resultHandler function will be provided with list of tokens
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listEvents(resultHandler) → {ConsulClient}

Returns the most recent events known by the agent
Parameters:
Name Type Description
resultHandler function will be provided with list of events
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listEventsWithOptions(options, resultHandler) → {ConsulClient}

Returns the most recent events known by the agent. This is blocking query unlike ConsulClient#listEvents. However, the semantics of this endpoint are slightly different. Most blocking queries provide a monotonic index and block until a newer index is available. This can be supported as a consequence of the total ordering of the consensus protocol. With gossip, there is no ordering, and instead X-Consul-Index maps to the newest event that matches the query. In practice, this means the index is only useful when used against a single agent and has no meaning globally. Because Consul defines the index as being opaque, clients should not be expecting a natural ordering either.
Parameters:
Name Type Description
options Object the blocking options
resultHandler function will be provided with list of events
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listNodeSessions(nodeId, resultHandler) → {ConsulClient}

Returns the active sessions for a given node
Parameters:
Name Type Description
nodeId string the ID of node
resultHandler function will be provided with list of sessions
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listNodeSessionsWithOptions(nodeId, options, resultHandler) → {ConsulClient}

Returns the active sessions for a given node This is blocking query unlike ConsulClient#listNodeSessions
Parameters:
Name Type Description
nodeId string the ID of node
options Object the blocking options
resultHandler function will be provided with list of sessions
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listSessions(resultHandler) → {ConsulClient}

Returns the active sessions
Parameters:
Name Type Description
resultHandler function will be provided with list of sessions
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

listSessionsWithOptions(options, resultHandler) → {ConsulClient}

Returns the active sessions This is blocking query unlike ConsulClient#listSessions
Parameters:
Name Type Description
options Object the blocking options
resultHandler function will be provided with list of sessions
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

localChecks(resultHandler) → {ConsulClient}

Return all the checks that are registered with the local agent.
Parameters:
Name Type Description
resultHandler function will be provided with list of checks
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

localServices(resultHandler) → {ConsulClient}

Returns list of services registered with the local agent.
Parameters:
Name Type Description
resultHandler function will be provided with list of services
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

maintenanceService(maintenanceOptions, resultHandler) → {ConsulClient}

Places a given service into "maintenance mode"
Parameters:
Name Type Description
maintenanceOptions Object the maintenance options
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

passCheck(checkId, resultHandler) → {ConsulClient}

Set status of the check to "passing". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

passCheckWithNote(checkId, note, resultHandler) → {ConsulClient}

Set status of the check to "passing". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
note string a human-readable message with the status of the check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

peersStatus(resultHandler) → {ConsulClient}

Retrieves the Raft peers for the datacenter in which the the agent is running. It returns a list of addresses "10.1.10.12:8300", "10.1.10.13:8300"
Parameters:
Name Type Description
resultHandler function will be provided with list of peers
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

putValue(key, value, resultHandler) → {ConsulClient}

Adds specified key/value pair
Parameters:
Name Type Description
key string the key
value string the value
resultHandler function will be provided with success of operation
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

putValueWithOptions(key, value, options, resultHandler) → {ConsulClient}

Parameters:
Name Type Description
key string the key
value string the value
options Object options used to push pair
resultHandler function will be provided with success of operation
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

registerCheck(checkOptions, resultHandler) → {ConsulClient}

Add a new check to the local agent. The agent is responsible for managing the status of the check and keeping the Catalog in sync.
Parameters:
Name Type Description
checkOptions Object options used to register new check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

registerService(serviceOptions, resultHandler) → {ConsulClient}

Adds a new service, with an optional health check, to the local agent.
Parameters:
Name Type Description
serviceOptions Object the options of new service
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

renewSession(id, resultHandler) → {ConsulClient}

Renews the given session. This is used with sessions that have a TTL, and it extends the expiration by the TTL
Parameters:
Name Type Description
id string the ID of session that should be renewed
resultHandler function will be provided with info of renewed session
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

transaction(request, resultHandler) → {ConsulClient}

Manages multiple operations inside a single, atomic transaction.
Parameters:
Name Type Description
request Object transaction request
resultHandler function will be provided with result of transaction
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

updateAclToken(token, idHandler) → {ConsulClient}

Update Acl token
Parameters:
Name Type Description
token Object properties of the token to be updated
idHandler function will be provided with ID of updated
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

updateCheck(checkId, status, resultHandler) → {ConsulClient}

Set status of the check to given status. Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
status Object new status of check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

updateCheckWithNote(checkId, status, note, resultHandler) → {ConsulClient}

Set status of the check to given status. Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
status Object new status of check
note string a human-readable message with the status of the check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

warnCheck(checkId, resultHandler) → {ConsulClient}

Set status of the check to "warning". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient

warnCheckWithNote(checkId, note, resultHandler) → {ConsulClient}

Set status of the check to "warning". Used with a check that is of the TTL type. The TTL clock will be reset.
Parameters:
Name Type Description
checkId string the ID of check
note string a human-readable message with the status of the check
resultHandler function will be called when complete
Source:
Returns:
reference to this, for fluency
Type
ConsulClient