Search documentation of phoenix_kit

# PhoenixKit.Emails.Supervisor (phoenix_kit v1.6.19)

View Source

Supervisor for PhoenixKit email tracking system.

This module manages all processes necessary for email tracking:

- SQS Worker for processing events from AWS SQS
- Additional processes (metrics, archiving, etc.)

## Integration into Parent Application

Add supervisor to your application's supervision tree:

    # In lib/your_app/application.ex
    def start(_type, _args) do
      children = [
        # ... your other processes

        # PhoenixKit Email Tracking
        PhoenixKit.Emails.Supervisor
      ]

      opts = [strategy: :one_for_one, name: YourApp.Supervisor]
      Supervisor.start_link(children, opts)
    end

## Configuration

Supervisor automatically reads settings from PhoenixKit Settings:

- `sqs_polling_enabled` - enable/disable SQS Worker
- `sqs_polling_interval_ms` - polling interval
- other SQS settings

## Process Management

    # Stop SQS Worker
    PhoenixKit.Emails.SQSWorker.pause()

    # Start SQS Worker
    PhoenixKit.Emails.SQSWorker.resume()

    # Check status
    PhoenixKit.Emails.SQSWorker.status()

## Monitoring

Supervisor provides information about process state:

    # Get list of child processes
    Supervisor.which_children(PhoenixKit.Emails.Supervisor)

    # Get process count
    Supervisor.count_children(PhoenixKit.Emails.Supervisor)

# Summary

## Functions

child_spec(init_arg)

Returns child spec for integration into parent supervisor.

restart_sqs_worker(supervisor \\ __MODULE__)

Stops and restarts SQS Worker.

start_link(opts \\ [])

Starts supervisor for email tracking system.

system_status(supervisor \\ __MODULE__)

Returns information about email tracking system status.

# Functions

# child_spec(init_arg)

Returns child spec for integration into parent supervisor.

This function is used when you want more precise control over email tracking integration in your application.

## Examples

    # In lib/your_app/application.ex
    def start(_type, _args) do
      children = [
        # ... other processes
        PhoenixKit.Emails.Supervisor.child_spec([])
      ]

      Supervisor.start_link(children, strategy: :one_for_one)
    end

# restart_sqs_worker(supervisor \\ __MODULE__)

Stops and restarts SQS Worker.

Useful for applying new configuration settings.

## Examples

    iex> PhoenixKit.Emails.Supervisor.restart_sqs_worker()
    :ok

# start_link(opts \\ [])

Starts supervisor for email tracking system.

## Options

- `:name` - supervisor process name (defaults to `__MODULE__`)

## Examples

    {:ok, pid} = PhoenixKit.Emails.Supervisor.start_link()

# system_status(supervisor \\ __MODULE__)

Returns information about email tracking system status.

## Examples

    iex> PhoenixKit.Emails.Supervisor.system_status()
    %{
      supervisor_running: true,
      sqs_worker_running: true,
      sqs_worker_status: %{polling_enabled: true, ...},
      children_count: 1
    }