# `Lockstep.RPC`
[🔗](https://github.com/b-erdem/lockstep/blob/v0.1.0/lib/lockstep/rpc.ex#L1)

Mirror of Erlang's `:rpc` module under Lockstep's controlled
scheduling. Cross-node `apply/4`-style calls are modeled by
spawning a process on the target node, having it execute the
function, and shipping the result back to the caller via a
Lockstep-controlled message.

Partition-aware: if the caller's node and the target are in
opposing partition groups, the spawn message itself is dropped or
deferred (per partition mode). Calls in `:drop` partitions error
with `{:badrpc, :nodedown}`-equivalent semantics; in `:defer`
partitions they hang until heal (and then complete).

## Supported

  * `call/4,5` -- synchronous remote call
  * `multicall/4,5` -- call same function on a list of nodes,
    gather successes and failures
  * `cast/4` -- fire-and-forget remote call
  * `abcast/2,3` -- async broadcast a message to a registered
    atom name on every node

# `abcast`

```elixir
@spec abcast(atom(), any()) :: :abcast
```

Single-arity abcast: broadcasts to all known nodes.

# `abcast`

```elixir
@spec abcast([atom()], atom(), any()) :: :abcast
```

Async-broadcast `msg` to a registered atom `name` on every node
in `nodes`. Mirrors `:rpc.abcast/3`.

# `call`

```elixir
@spec call(atom(), module(), atom(), [any()], timeout()) :: any()
```

Synchronous call: invoke `apply(module, fun, args)` on `node`,
return its result.

Returns the function's value, or `{:badrpc, reason}` on failure
(timeout, unreachable node, etc.) -- mirroring `:rpc.call/4-5`.

# `cast`

```elixir
@spec cast(atom(), module(), atom(), [any()]) :: true
```

Fire-and-forget call: `apply(module, fun, args)` on `node` with no
reply. Returns `true` (matching `:rpc.cast/4`'s contract).

# `multicall`

```elixir
@spec multicall([atom()], module(), atom(), [any()], timeout()) :: {[any()], [atom()]}
```

Call `apply(module, fun, args)` on each node in `nodes`. Returns
`{successes, bad_nodes}` where `successes` is the list of return
values (in node order) and `bad_nodes` is a list of nodes that
errored or timed out.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
