OTP Application callback module for ExCodecs.
Starts the shared ExCodecs.CodecRegistry catalog and registers all built-in
binary and spatial codecs during application startup.
Summary
Functions
Starts the ExCodecs supervision tree.
Functions
@spec start(Application.start_type(), term()) :: {:ok, pid()} | {:error, term()} | {:ok, pid(), term()}
Starts the ExCodecs supervision tree.
This callback starts ExCodecs.CodecRegistry, registers every built-in
codec entry, and supervises the registry with a :one_for_one
strategy. It is invoked by OTP when the :ex_codecs application starts;
application code should normally use Application.ensure_all_started/1
instead of calling this function directly.
Arguments
type—Application.start_type(). OTP supplies:normal,{:takeover, node}, or{:failover, node}; ExCodecs does not vary its startup behavior by type.args— startup term configured for the application. ExCodecs ignores this value.
Returns
{:ok, supervisor_pid}when the supervisor and registry start.{:error, reason}whenSupervisor.start_link/2cannot start the supervision tree.{:ok, supervisor_pid, state}is permitted by theApplication.start/2callback contract, but ExCodecs does not currently return that form.
Raises
This callback does not deliberately raise. OTP or supervisor internals may exit the calling process for unrecoverable startup failures.
Example
iex> {:ok, _apps} = Application.ensure_all_started(:ex_codecs)
iex> Process.whereis(ExCodecs.Supervisor) |> is_pid()
true
iex> ExCodecs.supports?(:zstd)
trueCallback implementation
An OTP application that embeds a similar registry can use the same shape:
defmodule MyApp.Application do
use Application
@impl Application
def start(_type, _args) do
children = [{ExCodecs.CodecRegistry, register: fn -> :ok end}]
Supervisor.start_link(children,
strategy: :one_for_one,
name: MyApp.Supervisor
)
end
end