View Source Skitter.Remote (Skitter v0.7.1)

Facilities to interact with remote Skitter runtimes.

This module offers facilities to query Skitter about the available remote Skitter runtimes and their properties. It also defines various functions which can be used to spawn Skitter workers on remote Skitter nodes.

Summary

Types

Worker tag.

Functions

Attempt to connect to remote.

Check if the local runtime is connected to the specified remote runtime.

Get the name of the master node of the cluster.

Execute a function n times on every worker runtime.

Execute fun on remote, block until a result is available.

Execute mod.func(args) on remote, block until a result is available.

Execute a function on every core on every worker runtime.

Execute a function on every worker runtime.

Execute a function on every worker runtime.

Execute fun on every specified remote runtime, obtain results in a list.

Execute mod.func(args) on every specified remote runtime, obtain results in a list.

Execute a function n times, distributed over the available workers.

Execute a function on every core on every worker runtime tagged with tag.

Execute a function on every worker runtime tagged with tag.

Get the name of the current Skitter runtime.

Get a list of all the tags of node().

Get a list of all the worker runtimes tagged with a given tag/0.

Get a list of the names of all the worker runtimes in the cluster.

Types

@type tag() :: atom()

Worker tag.

A worker may be started with a tag, which indicates properties of the node. For instance, a :gpu tag could be added to a node which has a gpu. Various functions in this module can be used to only spawn workers on nodes with given tags.

Functions

Link to this function

connect(remote, expected_mode \\ nil)

View Source
@spec connect(node(), atom()) :: {:ok, atom()} | {:error, atom()}

Attempt to connect to remote.

This function verifies if remote is a valid Skitter node and tries to connect to it. If the connection is successful, this functions tries to find a bound handler for the local mode. If this works, {:ok, mode} is returned, where mode is the mode of the remote runtime.

If the expected_mode argument is passed, connect/2 only connects to the remote runtime if its mode is equal to expected_mode.

The following errors may be returned if the connection does not succeed:

  • {:error, :not_distributed}: the local node is not alive according to Node.alive?/0
  • {:error, :not_connected}: it was not possible to connect to the remote runtime
  • {:error, :not_skitter}: the remote node is not a Skitter remote
  • {:error, :incompatible}: the remote node is running an incompatible version of Skitter
  • {:error, :mode_mismatch}: the mode of the remote runtime is not equal to expected_mode
  • {:error, :unknown_mode}: the remote or local runtime does not have a handler for the mode of the other runtime.
  • The handler of the local mode may return a custom {:error, reason} tuple.
@spec connected?(node()) :: boolean()

Check if the local runtime is connected to the specified remote runtime.

@spec master() :: node()

Get the name of the master node of the cluster.

Link to this function

n_times_on_all_workers(n, fun)

View Source
@spec n_times_on_all_workers(pos_integer(), (-> any())) :: [{node(), [any()]}]

Execute a function n times on every worker runtime.

A list of results will be returned for each worker node. These results will be returned in a keyword list of {worker, result} pairs.

@spec on(node(), (-> any())) :: any()

Execute fun on remote, block until a result is available.

Link to this function

on(remote, mod, func, args)

View Source
@spec on(node(), module(), atom(), [any()]) :: any()

Execute mod.func(args) on remote, block until a result is available.

Link to this function

on_all_worker_cores(fun)

View Source
@spec on_all_worker_cores((-> any())) :: [{node(), [any()]}]

Execute a function on every core on every worker runtime.

A list of results will be returned for each worker node. These results will be returned in a keyword list of {worker, result} pairs.

@spec on_all_workers((-> any())) :: [{node(), any()}]

Execute a function on every worker runtime.

The result of each worker will be returned in a keyword list of {worker, result} pairs.

Link to this function

on_all_workers(mod, func, args)

View Source
@spec on_all_workers(module(), atom(), [any()]) :: [{node(), any()}]

Execute a function on every worker runtime.

The result of each worker will be returned in a keyword list of {worker, result} pairs.

@spec on_many([node()], (-> any())) :: [{node(), any()}]

Execute fun on every specified remote runtime, obtain results in a list.

Link to this function

on_many(remotes, mod, func, args)

View Source
@spec on_many([node()], module(), atom(), [any()]) :: [{node(), any()}]

Execute mod.func(args) on every specified remote runtime, obtain results in a list.

@spec on_n(pos_integer(), (-> any())) :: [[any()]]

Execute a function n times, distributed over the available workers.

This is handy when you wish to create n workers distributed over the cluster. The work to be done will be divided over the worker nodes in a round robin fashion. This behaviour may change in the future.

Link to this function

on_tagged_worker_cores(tag, fun)

View Source
@spec on_tagged_worker_cores(tag(), (-> any())) :: [{node(), any()}]

Execute a function on every core on every worker runtime tagged with tag.

The result of each worker will be returned in a keyword list of {worker, result} pairs.

Link to this function

on_tagged_workers(tag, fun)

View Source
@spec on_tagged_workers(tag(), (-> any())) :: [{node(), any()}]

Execute a function on every worker runtime tagged with tag.

The result of each worker will be returned in a keyword list of {worker, result} pairs.

@spec self() :: node()

Get the name of the current Skitter runtime.

@spec tags(node()) :: [tag()]

Get a list of all the tags of node().

@spec with_tag(tag()) :: [node()]

Get a list of all the worker runtimes tagged with a given tag/0.

@spec workers() :: [node()]

Get a list of the names of all the worker runtimes in the cluster.