multiverses v0.5.0 Multiverses.GenServer View Source

This module is intended to be a drop-in replacement for use GenServer. Note that this is different from other modules.

Usage

defmodule MyModule do

  use Multiverses, with: GenServer
  use GenServer

  def start_link(...) do
    GenServer.start_link(__MODULE__, init, forward_callers: true)
  end

  #
  # standard GenServer code.
  #

end

The Multiverses.GenServer implementation introduces a :forward_callers option into the GenServer init, setting this to true, allows the GenServer to inherit the callers chain of its caller. This is compatible with Multiverses.DynamicSupervisor.

Important:

Typically you won't want GenServers to default to be part of a multiverse shard, as they generally represent stateful persistent internal services. If the service can exist before and after the test, then you should consider NOT using this module.

When you should use this module:

In some cases, a GenServer will represent a transient connection, or a cache for state IRL which is tracked in a specific context.

Link to this section Summary

Link to this section Functions

Link to this macro

abcast(p1, p2)

View Source (macro)

cloned from GenServer.abcast/2

Link to this macro

abcast(p1, p2, p3)

View Source (macro)

cloned from GenServer.abcast/3

cloned from GenServer.call/2

Link to this macro

call(p1, p2, p3)

View Source (macro)

cloned from GenServer.call/3

cloned from GenServer.cast/2

Link to this macro

format_report(p1)

View Source (macro)

cloned from GenServer.format_report/1

Link to this macro

multi_call(p1, p2)

View Source (macro)

cloned from GenServer.multi_call/2

Link to this macro

multi_call(p1, p2, p3)

View Source (macro)

cloned from GenServer.multi_call/3

Link to this macro

multi_call(p1, p2, p3, p4)

View Source (macro)

cloned from GenServer.multi_call/4

cloned from GenServer.reply/2

Link to this macro

start(module, init_state, opts \\ [])

View Source (macro)

starts a GenServer, linked to the calling function.

Link to this macro

start_link(module, init_state, opts \\ [])

View Source (macro)

starts a GenServer, linked to the calling function.

cloned from GenServer.stop/1

cloned from GenServer.stop/2

Link to this macro

stop(p1, p2, p3)

View Source (macro)

cloned from GenServer.stop/3

cloned from GenServer.whereis/1