Caracola.Call (Caracola v0.1.0-rc.1)

Copy Markdown View Source

Call process: every request, response and transaction with the same Call-ID is handled by a single process, which serializes all the work for that call. Equivalent to NkSIP's nksip_call_srv and nksip_router.

Call processes are started on demand, registered in a Registry of the service (which also enforces max_calls) and stop when they have no transactions or dialogs left. User callbacks run inside the call process and receive this struct as the call argument.

A process may stop right after a caller found it; in that case the work had not been received, and it is sent again to a new process.

Summary

Types

t()

The state of a call: all the transactions, forks and dialogs sharing a Call-ID, owned by one process per service and Call-ID.

Functions

Returns a specification to start this module under a supervisor.

Returns the number of calls of a service.

Returns the pid of a call process, if started.

Sends a piece of work to the process of a call, starting it if needed.

Types

t()

@type t() :: %Caracola.Call{
  auths: MapSet.t(),
  call_id: String.t(),
  config: keyword(),
  dialogs: %{required(Caracola.Dialog.id()) => Caracola.Dialog.t()},
  events: MapSet.t(),
  forks: %{required(pos_integer()) => term()},
  hibernate: term(),
  msgs: %{required(String.t()) => pos_integer()},
  next: pos_integer(),
  service: module(),
  start_time: term(),
  trans: %{required(pos_integer()) => term()}
}

The state of a call: all the transactions, forks and dialogs sharing a Call-ID, owned by one process per service and Call-ID.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count(service)

@spec count(module()) :: non_neg_integer()

Returns the number of calls of a service.

find(service, call_id)

@spec find(module(), String.t()) :: pid() | nil

Returns the pid of a call process, if started.

work(service, call_id, work, timeout \\ :infinity)

@spec work(module(), String.t(), term(), timeout()) :: term()

Sends a piece of work to the process of a call, starting it if needed.