Manic v0.0.2 Manic.Multi View Source

Module for encapsulating multiple miner Merchant API clients.

Link to this section Summary

Types

Multi miner API response

t()

Bitcoin multi miner API client

Functions

Sets the asynchronous operation on the given multi miner client.

Sets the asynchronous operation on the given multi miner client.

Returns a multi miner client for the given list of Merchant API endpoints.

Concurrently runs the asynchronous operation on the given multi miner client, yielding the response from any or all of the miners.

Link to this section Types

Link to this type

result()

View Source
result() ::
  {Manic.miner(), {:ok, any()}} | [{Manic.miner(), {:ok | :error, any()}}, ...]

Multi miner API response

Link to this type

t()

View Source
t() :: %Manic.Multi{
  miners: list(),
  operation: {atom(), atom(), list()} | function(),
  yield: :any | :all
}

Bitcoin multi miner API client

Link to this section Functions

Link to this function

async(multi, operation)

View Source
async(t(), function()) :: t()

Sets the asynchronous operation on the given multi miner client.

The operation is an inline function which receives the miner client.

Example

iex> Manic.Multi.async(multi, fn miner ->
...>   MyModule.some_function(miner)
...> end)

Or, the same more succinctly:

iex> Manic.Multi.async(multi, &MyModule.some_function/1)
Link to this function

async(multi, module, function_name, args)

View Source
async(t(), atom(), atom(), list()) :: t()

Sets the asynchronous operation on the given multi miner client.

The operation is passed as a tuple containing the module, function name and list or arguments. In this case, the miner client will automatically be prepended to the list of arguments.

Example

iex> Manic.Multi.async(multi, MyModule, :some_function, args)
Link to this function

new(miners, options \\ [])

View Source
new(list(), keyword()) :: t()

Returns a multi miner client for the given list of Merchant API endpoints.

Link to this function

yield(multi, timeout \\ 5000)

View Source
yield(t(), integer() | :infinity) :: result()

Concurrently runs the asynchronous operation on the given multi miner client, yielding the response from any or all of the miners.

By default, multi miner operations will yield until any of the miners respond. Alternatively, a multi client can be initialized with the option yield: :all which awaits for all miner clients to respond.