Poolder.FactoryPool behaviour (Poolder v0.1.9)

View Source

Dynamic pool of grouped processes with fast lookup by group or pid.

Usage examples

# Start a worker under group :http Poolder.FactoryPool.start_child(:http, {MyWorker, args})

# Synchronous call to specific pid Poolder.FactoryPool.call(pid, :ping)

# Async message to a specific pid Poolder.FactoryPool.cast(pid, :refresh)

# Broadcast to all workers in a group Poolder.FactoryPool.broadcast(:http, :reload)

# Count active workers in a group Poolder.FactoryPool.count(:http)

Summary

Callbacks

broadcast(group, msg)

@callback broadcast(group :: atom(), msg :: any()) :: :ok

call(pid, msg)

@callback call(pid :: pid(), msg :: any()) :: any()

call(group, pid, msg)

@callback call(group :: atom(), pid :: pid(), msg :: any()) :: any()

cast(pid, msg)

@callback cast(pid :: pid(), msg :: any()) :: :ok

cast(group, pid, msg)

@callback cast(group :: atom(), pid :: pid(), msg :: any()) :: :ok

count(group)

@callback count(group :: atom()) :: non_neg_integer()

count_all()

@callback count_all() :: non_neg_integer()

list(group)

@callback list(group :: atom()) :: [pid()]

list_all()

@callback list_all() :: [{pid(), atom()}]

start_child(group, {})

@callback start_child(
  group :: atom(),
  {module(), args :: any()}
) :: {:ok, pid()} | {:error, any()}

start_link()

@callback start_link() :: {:ok, pid()} | :ignore

terminate(pid)

@callback terminate(pid :: pid()) :: :ok | {:error, any()}

terminate_group(group)

@callback terminate_group(group :: atom()) :: :ok | {:error, any()}