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-:prodor: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"}
Summary
Functions
Checks if APNS is configured.
Gets the APNS Key ID.
Gets the APNS mode (:prod or :sandbox).
Gets the APNS private key content. Supports file paths, environment variables, and raw strings.
Gets the APNS Team ID.
Gets the cooldown time in milliseconds before the circuit transitions
from :open to :half_open.
Default: 30 seconds.
Checks if the circuit breaker is enabled.
Default: false (opt-in feature).
Gets the number of consecutive failures before the circuit opens. Default: 5.
Gets the TCP connection timeout in milliseconds. Default: 10 seconds.
Checks if FCM is configured.
Gets the FCM credentials for Goth. Returns a map suitable for Goth configuration.
Gets the FCM project ID.
Gets the Finch pool name.
Gets the Finch pool count (number of connection pools).
Gets the Finch pool size (connections per pool).
Returns the Finch request options with configured timeouts.
Gets a configuration value.
Gets a required configuration value. Raises if the value is not configured.
Gets the callback for invalid token cleanup.
Gets the pool timeout (time to wait for a connection from pool) in milliseconds. Default: 5 seconds.
Gets the receive timeout (time to wait for response data) in milliseconds. Default: 15 seconds.
Gets the overall request timeout in milliseconds. Default: 30 seconds.
Gets the base delay for exponential backoff in milliseconds. Default: 10 seconds (Google's recommended minimum).
Checks if retry is enabled.
Gets the maximum number of retry attempts.
Gets the maximum delay for exponential backoff in milliseconds. Default: 60 seconds.
Functions
@spec apns_configured?() :: boolean()
Checks if APNS is configured.
@spec apns_key_id() :: String.t()
Gets the APNS Key ID.
@spec apns_mode() :: :prod | :sandbox
Gets the APNS mode (:prod or :sandbox).
@spec apns_private_key() :: String.t()
Gets the APNS private key content. Supports file paths, environment variables, and raw strings.
@spec apns_team_id() :: String.t()
Gets the APNS Team ID.
@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.
@spec circuit_breaker_enabled?() :: boolean()
Checks if the circuit breaker is enabled.
Default: false (opt-in feature).
@spec circuit_breaker_threshold() :: pos_integer()
Gets the number of consecutive failures before the circuit opens. Default: 5.
@spec connect_timeout() :: pos_integer()
Gets the TCP connection timeout in milliseconds. Default: 10 seconds.
@spec fcm_configured?() :: boolean()
Checks if FCM is configured.
Gets the FCM credentials for Goth. Returns a map suitable for Goth configuration.
@spec fcm_project_id() :: String.t()
Gets the FCM project ID.
@spec finch_name() :: atom()
Gets the Finch pool name.
@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)
@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)
@spec finch_request_opts() :: keyword()
Returns the Finch request options with configured timeouts.
Gets a configuration value.
Gets a required configuration value. Raises if the value is not configured.
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, []}
@spec pool_timeout() :: pos_integer()
Gets the pool timeout (time to wait for a connection from pool) in milliseconds. Default: 5 seconds.
@spec receive_timeout() :: pos_integer()
Gets the receive timeout (time to wait for response data) in milliseconds. Default: 15 seconds.
@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_timeoutand:pool_timeoutinstead.
@spec retry_base_delay_ms() :: pos_integer()
Gets the base delay for exponential backoff in milliseconds. Default: 10 seconds (Google's recommended minimum).
@spec retry_enabled?() :: boolean()
Checks if retry is enabled.
@spec retry_max_attempts() :: pos_integer()
Gets the maximum number of retry attempts.
@spec retry_max_delay_ms() :: pos_integer()
Gets the maximum delay for exponential backoff in milliseconds. Default: 60 seconds.