Raxol.Protocols.CoreProtocols.Lifecycle protocol (Raxol v2.0.1)

View Source

Protocol for managing component/module lifecycle. Handles initialization, startup, shutdown, and cleanup.

Summary

Types

t()

All the types that implement this protocol.

Functions

Cleans up resources used by the component/module.

Gets the current lifecycle state.

Initializes the component/module with given options.

Restarts the component/module.

Starts the component/module.

Stops the component/module.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

cleanup(component)

@spec cleanup(t()) :: :ok

Cleans up resources used by the component/module.

get_state(component)

@spec get_state(t()) ::
  :initialized | :starting | :running | :stopping | :stopped | :error

Gets the current lifecycle state.

initialize(component, opts \\ [])

@spec initialize(
  t(),
  keyword()
) :: {:ok, t()} | {:error, any()}

Initializes the component/module with given options.

restart(component)

@spec restart(t()) :: {:ok, t()} | {:error, any()}

Restarts the component/module.

start(component)

@spec start(t()) :: {:ok, t()} | {:error, any()}

Starts the component/module.

stop(component)

@spec stop(t()) :: {:ok, t()} | {:error, any()}

Stops the component/module.