View Source Cluster.Strategy.Droplet (libcluster_droplet v1.0.0)

Digital Ocean Droplet strategy for libcluster

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the Droplet metadata top-level index, or specific metadata values.

Makes a request to the Digital Ocean API for a list of droplets and recurses through the pages.

Starts a GenServer to poll the Digital Ocean API for a list of nodes to add to the cluster.

Converts a droplet map returned from the Digital Ocean API to a node name such as :"foobar@127.0.0.1".

Converts a list of droplet maps to node names as explained in to_node_name/2.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Returns the Droplet metadata top-level index, or specific metadata values.

See https://docs.digitalocean.com/products/droplets/how-to/retrieve-droplet-metadata/

Link to this function

get_nodes(state, url, token, id)

View Source

Makes a request to the Digital Ocean API for a list of droplets and recurses through the pages.

Will return a parsed list of node names derived from the droplet objects. Expects a full URL and a valid access token to be passed. Logs a warning and returns :error if the API didn't return a successful response.

Starts a GenServer to poll the Digital Ocean API for a list of nodes to add to the cluster.

Any nodes currently in the cluster that are no longer returned from the API will be removed from the cluster. Filtering can be done by tag name or Droplet name, but not both. Otherwise an exception will be raised. The current Droplet will be excluded so the node doesn't try to connect to itself.

If there is an issue making the API request, the node list is kept as is with no changes. This is because we don't want all the nodes tp disconnect from each other if the Digital Ocean API goes down.

Link to this function

to_node_name(state, droplet)

View Source

Converts a droplet map returned from the Digital Ocean API to a node name such as :"foobar@127.0.0.1".

Logs a warning and returns nil if the droplet doesn't have an address for the defined network type and ip version.

Link to this function

to_node_names(state, droplets, id \\ nil)

View Source

Converts a list of droplet maps to node names as explained in to_node_name/2.

Will not return node names for droplets that don't have a status of "active", or that match the provided ID.