View Source Please.Requests (Please v0.1.0)

An agent listing all requests that have been made to the network.

The first list holds the requests that this node is asking to be resolved, while the second list holds the requests that this node is resolving itself.

It's possible to request the busyness of another node in relation to performing a certain request. The other node should return an integer with the priority of the node to handle the request (with any offset applied) or nil if the node simply cannot handle the request in any way.

Nodes handle their own busyness level, which increases or decreases as they accept and finish requests. It is possible to configure the node in such a way that certain requests alter the busyness level of the node in varying levels. This way, the node can be configured to prefer certain types of requests over others.

Summary

Functions

Get the acceptance priority of a given request for the current node.

Get the acceptance priority of a given request for a specific node.

Add a request.

Get the base busyness of the local node.

Get the base busyness of the local node.

Decrease the base busyness of the local node.

Increase the base busyness of the local node.

Get the busyness of the local node.

Fetch custom busyness weights for certain modules and functions.

Fetch the busyness weight for a request. If the weight is nil, the request can't be handled by the current node. It's possible to configure a rejection by setting the weight to :reject.

Returns a specification to start this module under a supervisor.

Delegate a request to another node.

Get all known requests.

Get a request by its ID.

Get all handling requests.

Get a handling request by its ID.

Get all pending requests.

Get a pending request by its ID.

Handle a request, returning the output to the requester PID.

Pick a request to be handled.

Remove a request.

Start the agent.

Functions

Link to this function

acceptance_priority(request)

View Source
@spec acceptance_priority(Please.Requests.Request.t()) :: integer() | nil

Get the acceptance priority of a given request for the current node.

To see the documentation of the aceptance_priority function called by the agent itself, see the documentation of the function with the same name that takes two arguments.

Link to this function

acceptance_priority(node, request)

View Source
@spec acceptance_priority(
  atom() | {atom(), map(), integer()},
  Please.Requests.Request.t()
) ::
  integer() | nil

Get the acceptance priority of a given request for a specific node.

The node can be an atom or a tuple with the node atom and the state map.

The first case is intended to be used to request the acceptance priority of a node that is not the current node. The second case is intended to be the version of the function that is called by the agent itself when asked remotely, as it will have the agent state as the first argument, and the request as the second argument.

@spec add(Please.Requests.Request.t()) :: :ok | :error

Add a request.

@spec base_busyness() :: integer()

Get the base busyness of the local node.

@spec base_busyness(atom()) :: integer()

Get the base busyness of the local node.

Link to this function

base_busyness_decrease(amount \\ 100)

View Source
@spec base_busyness_decrease(integer()) :: integer()

Decrease the base busyness of the local node.

Link to this function

base_busyness_increase(amount \\ 100)

View Source
@spec base_busyness_increase(integer()) :: integer()

Increase the base busyness of the local node.

@spec busyness() :: integer()

Get the busyness of the local node.

@spec busyness_weights() :: map()

Fetch custom busyness weights for certain modules and functions.

Link to this function

busyness_weights(request_id)

View Source
@spec busyness_weights(Please.Requests.Request.t() | String.t() | nil) ::
  integer() | nil

Fetch the busyness weight for a request. If the weight is nil, the request can't be handled by the current node. It's possible to configure a rejection by setting the weight to :reject.

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delegate(node, request_id)

View Source
@spec delegate(atom(), Please.Requests.Request.t() | String.t()) :: :ok | :error

Delegate a request to another node.

@spec get() :: list()

Get all known requests.

@spec get(String.t()) :: Please.Requests.Request.t() | nil

Get a request by its ID.

@spec get_handling() :: list()

Get all handling requests.

Link to this function

get_handling(request_id)

View Source
@spec get_handling(String.t()) :: Please.Requests.Request.t() | nil

Get a handling request by its ID.

@spec get_pending() :: list()

Get all pending requests.

@spec get_pending(String.t()) :: Please.Requests.Request.t() | nil

Get a pending request by its ID.

@spec handle(Please.Requests.Request.t() | String.t()) :: :ok | :error

Handle a request, returning the output to the requester PID.

The requester will receive a tuple with the module name, the function name, the ID of the request, and the output of the function call, inside a tuple.

If the function call raises an error, the requester will receive a tuple with the module name, the atom :error name, the request itself, and the error message, inside a tuple.

@spec pick(Please.Requests.Request.t() | String.t()) :: :ok | :error

Pick a request to be handled.

@spec remove(Please.Requests.Request.t() | String.t()) :: :ok | :error

Remove a request.

@spec start_link(any()) :: {:ok, pid()}

Start the agent.