# `PushX.Config`
[🔗](https://github.com/cignosystems/pushx/blob/v0.11.0/lib/push_x/config.ex#L1)

Configuration management for PushX.

## Configuration Options

### APNS (Apple Push Notification Service)

  * `:apns_key_id` - The Key ID from Apple Developer Portal
  * `:apns_team_id` - Your Apple Developer Team ID
  * `:apns_private_key` - The private key, either:
    * A raw PEM string
    * `{:file, "/path/to/AuthKey.p8"}`
    * `{:system, "ENV_VAR_NAME"}`
  * `:apns_mode` - `:prod` or `:sandbox` (default: `:prod`)

### FCM (Firebase Cloud Messaging)

  * `:fcm_project_id` - Your Firebase project ID
  * `:fcm_credentials` - Service account credentials, either:
    * `{:file, "/path/to/service-account.json"}`
    * `{:json, "...json string..."}`
    * `{:system, "ENV_VAR_NAME"}` (expects JSON string)

### Finch Pool

  * `:finch_name` - Name of the Finch pool (default: `PushX.Finch`)
  * `:finch_pool_size` - Connections per pool (default: 25)
  * `:finch_pool_count` - Number of pools (default: 2)

### Request Timeouts

  * `:receive_timeout` - Timeout for receiving response in ms (default: `15_000`)
  * `:pool_timeout` - Timeout for acquiring connection from pool in ms (default: `5_000`)
  * `:connect_timeout` - TCP connection timeout in ms (default: `10_000`)

### Retry Settings

  * `:retry_enabled` - Enable automatic retry (default: `true`)
  * `:retry_max_attempts` - Maximum retry attempts (default: `3`)
  * `:retry_base_delay_ms` - Base delay in milliseconds (default: `10_000`)
  * `:retry_max_delay_ms` - Maximum delay in milliseconds (default: `60_000`)

## Example Configuration

    config :pushx,
      apns_key_id: "ABC123DEFG",
      apns_team_id: "TEAM123456",
      apns_private_key: {:file, "priv/keys/AuthKey.p8"},
      apns_mode: :prod,
      fcm_project_id: "my-project-id",
      fcm_credentials: {:file, "priv/keys/firebase.json"}

# `apns_configured?`

```elixir
@spec apns_configured?() :: boolean()
```

Checks if APNS is configured.

# `apns_key_id`

```elixir
@spec apns_key_id() :: String.t()
```

Gets the APNS Key ID.

# `apns_mode`

```elixir
@spec apns_mode() :: :prod | :sandbox
```

Gets the APNS mode (:prod or :sandbox).

# `apns_private_key`

```elixir
@spec apns_private_key() :: String.t()
```

Gets the APNS private key content.
Supports file paths, environment variables, and raw strings.

# `apns_team_id`

```elixir
@spec apns_team_id() :: String.t()
```

Gets the APNS Team ID.

# `circuit_breaker_cooldown_ms`

```elixir
@spec circuit_breaker_cooldown_ms() :: pos_integer()
```

Gets the cooldown time in milliseconds before the circuit transitions
from `:open` to `:half_open`.
Default: 30 seconds.

# `circuit_breaker_enabled?`

```elixir
@spec circuit_breaker_enabled?() :: boolean()
```

Checks if the circuit breaker is enabled.
Default: `false` (opt-in feature).

# `circuit_breaker_threshold`

```elixir
@spec circuit_breaker_threshold() :: pos_integer()
```

Gets the number of consecutive failures before the circuit opens.
Default: 5.

# `connect_timeout`

```elixir
@spec connect_timeout() :: pos_integer()
```

Gets the TCP connection timeout in milliseconds.
Default: 10 seconds.

# `fcm_configured?`

```elixir
@spec fcm_configured?() :: boolean()
```

Checks if FCM is configured.

# `fcm_credentials`

```elixir
@spec fcm_credentials() :: map() | {:file, String.t()}
```

Gets the FCM credentials for Goth.
Returns a map suitable for Goth configuration.

# `fcm_project_id`

```elixir
@spec fcm_project_id() :: String.t()
```

Gets the FCM project ID.

# `finch_name`

```elixir
@spec finch_name() :: atom()
```

Gets the Finch pool name.

# `finch_pool_count`

```elixir
@spec finch_pool_count() :: pos_integer()
```

Gets the Finch pool count (number of connection pools).

Default: 2 (increased from 1 in v0.6.0 to handle traffic bursts better)

# `finch_pool_size`

```elixir
@spec finch_pool_size() :: pos_integer()
```

Gets the Finch pool size (connections per pool).

Default: 25 (increased from 10 in v0.6.0 to handle traffic bursts better)

# `finch_request_opts`

```elixir
@spec finch_request_opts() :: keyword()
```

Returns the Finch request options with configured timeouts.

# `get`

```elixir
@spec get(atom(), any()) :: any()
```

Gets a configuration value.

# `get!`

```elixir
@spec get!(atom()) :: any()
```

Gets a required configuration value.
Raises if the value is not configured.

# `on_invalid_token`

```elixir
@spec on_invalid_token() :: {module(), atom(), list()} | nil
```

Gets the callback for invalid token cleanup.

When set, this MFA tuple is called asynchronously whenever a push
returns `:invalid_token`, `:expired_token`, or `:unregistered`.

The callback receives `(provider, token, ...extra_args)`.

## Example

    config :pushx,
      on_invalid_token: {MyApp.Push, :handle_invalid_token, []}

# `pool_timeout`

```elixir
@spec pool_timeout() :: pos_integer()
```

Gets the pool timeout (time to wait for a connection from pool) in milliseconds.
Default: 5 seconds.

# `receive_timeout`

```elixir
@spec receive_timeout() :: pos_integer()
```

Gets the receive timeout (time to wait for response data) in milliseconds.
Default: 15 seconds.

# `request_timeout`

> This function is deprecated. Not used by Finch. Use receive_timeout/0 and pool_timeout/0 instead..

```elixir
@spec request_timeout() :: pos_integer()
```

Gets the overall request timeout in milliseconds.
Default: 30 seconds.

> Note: This value is not currently passed to Finch requests.
> Use `:receive_timeout` and `:pool_timeout` instead.

# `retry_base_delay_ms`

```elixir
@spec retry_base_delay_ms() :: pos_integer()
```

Gets the base delay for exponential backoff in milliseconds.
Default: 10 seconds (Google's recommended minimum).

# `retry_enabled?`

```elixir
@spec retry_enabled?() :: boolean()
```

Checks if retry is enabled.

# `retry_max_attempts`

```elixir
@spec retry_max_attempts() :: pos_integer()
```

Gets the maximum number of retry attempts.

# `retry_max_delay_ms`

```elixir
@spec retry_max_delay_ms() :: pos_integer()
```

Gets the maximum delay for exponential backoff in milliseconds.
Default: 60 seconds.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
