Centralized defaults for all configurable values in Snakepit.
This module provides functions that read from Application.get_env(:snakepit, key, default)
for every configurable value. This allows operators to override defaults via application
configuration while maintaining backward compatibility.
All defaults are the EXACT values that were previously hardcoded throughout the codebase. Snakepit behaves identically before and after this change unless configuration is explicitly provided.
Configuration Example
# config/runtime.exs
config :snakepit,
# Timeouts
default_command_timeout: 30_000,
pool_request_timeout: 60_000,
pool_streaming_timeout: 300_000,
pool_startup_timeout: 10_000,
pool_queue_timeout: 5_000,
checkout_timeout: 5_000,
grpc_worker_execute_timeout: 30_000,
grpc_worker_stream_timeout: 300_000,
grpc_command_timeout: 30_000,
executor_batch_timeout: 30_000,
health_check_interval: 30_000,
circuit_breaker_reset_timeout: 30_000,
graceful_shutdown_timeout_ms: 6_000,
# Pool settings
pool_max_queue_size: 1000,
pool_max_workers: 150,
pool_max_cancelled_entries: 1024,
pool_cancelled_retention_multiplier: 4,
pool_startup_batch_size: 10,
pool_startup_batch_delay_ms: 500,
# Retry settings
retry_max_attempts: 3,
retry_max_backoff_ms: 30_000,
retry_jitter_factor: 0.25,
retry_backoff_sequence: [100, 200, 400, 800, 1600],
# Circuit breaker settings
circuit_breaker_failure_threshold: 5,
circuit_breaker_half_open_max_calls: 1,
# Crash barrier settings
crash_barrier_taint_duration_ms: 60_000,
crash_barrier_max_restarts: 1,
crash_barrier_backoff_ms: [50, 100, 200],
# Health monitor settings
health_monitor_crash_window_ms: 60_000,
health_monitor_max_crashes: 10,
# Lifecycle manager settings
lifecycle_check_interval: 60_000,
lifecycle_health_check_interval: 300_000,
lifecycle_check_max_concurrency: 8,
lifecycle_worker_action_timeout_ms: 2_000,
# Session store settings
session_cleanup_interval: 60_000,
session_default_ttl: 3600,
session_max_sessions: 10_000,
session_warning_threshold: 0.8,
affinity: :hint,
# Process registry settings
process_registry_cleanup_interval: 30_000,
process_registry_unregister_cleanup_delay: 500,
process_registry_unregister_cleanup_attempts: 10,
process_registry_dets_flush_interval_ms: 25,
# gRPC settings
grpc_num_acceptors: 20,
grpc_max_connections: 1000,
grpc_socket_backlog: 512,
grpc_stream_open_timeout_ms: 5_000,
grpc_stream_control_timeout_ms: 2_000,
# Heartbeat settings
heartbeat_ping_interval_ms: 2_000,
heartbeat_timeout_ms: 10_000,
heartbeat_max_missed: 3,
heartbeat_initial_delay_ms: 0Usage
Instead of hardcoding values like 30_000, modules now call:
Snakepit.Defaults.default_command_timeout()This returns the configured value or the original default if not configured.
Timeout Profiles (v0.8.8+)
Snakepit supports profile-based timeout configuration for different deployment scenarios:
| Profile | default_timeout | stream_timeout | queue_timeout |
|---|---|---|---|
| :balanced | 300_000 (5m) | 900_000 (15m) | 10_000 (10s) |
| :production | 300_000 (5m) | 900_000 (15m) | 10_000 (10s) |
| :production_strict | 60_000 (60s) | 300_000 (5m) | 5_000 (5s) |
| :development | 900_000 (15m) | 3_600_000 (60m) | 60_000 (60s) |
| :ml_inference | 900_000 (15m) | 3_600_000 (60m) | 60_000 (60s) |
| :batch | 3_600_000 (60m) | :infinity | 300_000 (5m) |
Configure via:
config :snakepit, timeout_profile: :productionLegacy per-key configuration is still supported and takes precedence when set.
Summary
Functions
TTL for session affinity cache entries in seconds.
Used in Snakepit.Pool for ETS affinity caching.
Default timeout for checking out a worker for streaming.
Used in Snakepit.Pool for worker checkout during streaming operations.
Default failure threshold before circuit opens.
Used in Snakepit.CircuitBreaker.
Default max calls allowed in half-open state.
Used in Snakepit.CircuitBreaker.
Default reset timeout before transitioning to half-open.
Used in Snakepit.CircuitBreaker.
Timeout for cleanup on stop.
Used in Snakepit.Application.
Poll interval for cleanup operations.
Used in Snakepit.Application.
Default batch delay for process profile.
Used in Snakepit.Config.
Default batch size for process profile.
Used in Snakepit.Config.
Default threads per worker for thread profile.
Used in Snakepit.Config.
Default backoff sequence for crash barrier retries.
Used in Snakepit.CrashBarrier.
Timeout for checking out worker during crash barrier retry.
Used in Snakepit.Pool crash barrier retry logic.
Default max restarts for crash barrier retry.
Used in Snakepit.CrashBarrier.
Default taint duration for crashed workers.
Used in Snakepit.CrashBarrier.
Default session affinity mode for pools.
Default capacity strategy.
Used in Snakepit.Config.
Default command timeout for worker execute operations.
Used in Snakepit.Pool for command timeout calculation.
Default pool size based on system schedulers. Used when no explicit pool_size is configured.
Returns the default timeout for regular execute operations based on the current profile.
Default worker profile.
Used in Snakepit.Config.
Default timeout for batch operations in Executor.
Used in Snakepit.Executor.execute_batch/2.
Graceful shutdown timeout for Python process termination. Must be >= Python's shutdown envelope: server.stop(2s) + wait_for_termination(3s) = 5s.
Timeout for batch inference commands.
Used in Snakepit.Adapters.GRPCPython for batch inference operations.
Default timeout for gRPC client execute calls.
Used in Snakepit.GRPC.Client.
Default command timeout for gRPC adapter.
Used in Snakepit.Adapters.GRPCPython for default command timeouts.
Default host for internal-only gRPC listeners.
Used when grpc_listener.mode is :internal.
Timeout for large dataset processing commands.
Used in Snakepit.Adapters.GRPCPython for large dataset processing operations.
Interval (ms) between port readiness checks when reusing an existing gRPC listener.
Timeout for waiting on the gRPC listener to publish its assigned port.
Number of attempts to reuse or rebind a gRPC listener before failing.
Delay (ms) between gRPC listener reuse retries.
Max wait (ms) for an already-started gRPC listener to publish its port before retrying.
Default maximum connections for gRPC server.
Used in Snakepit.Application.
Default number of acceptors for gRPC server.
Used in Snakepit.Application.
Default gRPC port for Elixir server.
Legacy: used when grpc_listener is not configured.
Default port pool size for external pooled listeners.
Used when grpc_listener.mode is :external_pool.
Timeout for waiting for gRPC server to become ready.
Used in Snakepit.GRPCWorker during initialization.
Default socket backlog for gRPC server.
Used in Snakepit.Application.
Timeout for sending telemetry control messages to Python workers.
Used in Snakepit.Telemetry.GrpcStream.
Timeout for opening telemetry streams to Python workers.
Used in Snakepit.Telemetry.GrpcStream.
Default timeout for GRPCWorker execute calls.
Used in Snakepit.GRPCWorker.execute/4.
Interval for health checks in GRPCWorker.
Used in Snakepit.GRPCWorker for periodic health check scheduling.
Timeout for periodic GRPCWorker health-check RPCs.
Used in Snakepit.GRPCWorker when issuing Client.health/3.
Default timeout for GRPCWorker streaming calls.
Used in Snakepit.GRPCWorker.execute_stream/5.
Default interval for health monitor cleanup.
Used in Snakepit.HealthMonitor.
Default crash window for health monitor. Rolling window for crash counting.
Default max crashes before pool is considered unhealthy.
Used in Snakepit.HealthMonitor.
Initial delay before starting heartbeat monitoring.
Used in Snakepit.GRPCWorker heartbeat configuration.
Maximum missed heartbeats before worker is considered unhealthy.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default heartbeat ping interval.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default heartbeat timeout.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default instance token for runtime isolation.
Default interval for lifecycle checks.
Used in Snakepit.Worker.LifecycleManager.
Maximum concurrent workers evaluated during each lifecycle check cycle.
Used in Snakepit.Worker.LifecycleManager.
Default interval for health checks in lifecycle manager.
Used in Snakepit.Worker.LifecycleManager.
Timeout (ms) per worker action during lifecycle check tasks.
Used in Snakepit.Worker.LifecycleManager.
Default timeout for awaiting pool readiness.
Used in Snakepit.Pool.await_ready/2.
Multiplier for cancelled request retention time. Retention time = queue_timeout * this multiplier.
Maximum number of cancelled request entries to track.
Used in Snakepit.Pool for cancelled request management.
Maximum queue size for pending requests.
Used in Snakepit.Pool for queue management.
Maximum number of workers allowed per pool.
Used in Snakepit.Pool for worker limit enforcement.
Default timeout for queued requests.
Used in Snakepit.Pool for queue management.
Margin reserved for pool reply overhead.
Default timeout for pool execute calls.
Used in Snakepit.Pool.execute/3.
Delay between worker startup batches in milliseconds.
Used in Snakepit.Pool for batched startup.
Number of workers to start per batch during pool initialization.
Used in Snakepit.Pool for batched startup.
Default timeout for worker startup. Used in pool initialization.
Default timeout for pool streaming calls.
Used in Snakepit.Pool.execute_stream/4.
Whether process-group based termination is enabled. Used in cleanup and worker shutdown paths.
Default cleanup interval for process registry.
Used in Snakepit.Pool.ProcessRegistry.
Interval (ms) for batching DETS fsync operations in Snakepit.Pool.ProcessRegistry.
Maximum attempts to retry unregister cleanup.
Used in Snakepit.Pool.ProcessRegistry.
Delay before retrying unregister when external process is still alive.
Used in Snakepit.Pool.ProcessRegistry.
Returns the default queue timeout based on the current profile.
Default backoff multiplier for exponential backoff.
Used in Snakepit.RetryPolicy.
Default backoff sequence for retries.
Used in Snakepit.RetryPolicy.
Default base backoff for retry calculations.
Used in Snakepit.RetryPolicy.
Default jitter factor for retry delays.
Used in Snakepit.RetryPolicy.
Default maximum retry attempts.
Used in Snakepit.RetryPolicy.
Default maximum backoff delay.
Used in Snakepit.RetryPolicy.
Default rogue cleanup configuration.
Used in Snakepit.Pool.ProcessRegistry.
Default command markers used to identify run ids for rogue cleanup.
Default script names considered for rogue cleanup process matching.
Derives the RPC (inner) timeout from the total timeout budget.
Default cleanup interval for expired sessions.
Used in Snakepit.Bridge.SessionStore.
Default TTL for sessions in seconds.
Used in Snakepit.Bridge.SessionStore.
Default maximum number of sessions.
Used in Snakepit.Bridge.SessionStore.
Session warning threshold as a fraction of max_sessions. When session count exceeds this percentage, warnings are emitted.
Margin added to graceful_shutdown_timeout for supervisor shutdown. This gives the worker time to complete its terminate/2 callback.
Returns the default timeout for streaming operations based on the current profile.
Returns the currently configured timeout profile.
Returns all available timeout profiles.
Margin reserved for GenServer.call overhead when routing to workers.
Timeout for worker ready notification to pool.
Used in Snakepit.GRPCWorker when notifying pool of readiness.
Maximum retries while waiting for worker external resource cleanup.
Used in Snakepit.Pool.WorkerSupervisor.
Retry interval in milliseconds while polling for worker external resource cleanup.
Used in Snakepit.Pool.WorkerSupervisor.
Functions
@spec affinity_cache_ttl_seconds() :: pos_integer()
TTL for session affinity cache entries in seconds.
Used in Snakepit.Pool for ETS affinity caching.
Default: 60 seconds (1 minute)
@spec checkout_timeout() :: timeout()
Default timeout for checking out a worker for streaming.
Used in Snakepit.Pool for worker checkout during streaming operations.
When not explicitly configured, derives from queue_timeout/0 based on the
current timeout profile.
Default: derived from profile (10_000 ms for :balanced)
@spec circuit_breaker_failure_threshold() :: pos_integer()
Default failure threshold before circuit opens.
Used in Snakepit.CircuitBreaker.
Default: 5
@spec circuit_breaker_half_open_max_calls() :: pos_integer()
Default max calls allowed in half-open state.
Used in Snakepit.CircuitBreaker.
Default: 1
@spec circuit_breaker_reset_timeout_ms() :: pos_integer()
Default reset timeout before transitioning to half-open.
Used in Snakepit.CircuitBreaker.
Default: 30_000 ms (30 seconds)
@spec cleanup_on_stop_timeout_ms() :: pos_integer()
Timeout for cleanup on stop.
Used in Snakepit.Application.
Default: 3_000 ms (3 seconds)
@spec cleanup_poll_interval_ms() :: pos_integer()
Poll interval for cleanup operations.
Used in Snakepit.Application.
Default: 50 ms
@spec config_default_batch_delay() :: pos_integer()
Default batch delay for process profile.
Used in Snakepit.Config.
Default: same as pool_startup_batch_delay_ms/0
@spec config_default_batch_size() :: pos_integer()
Default batch size for process profile.
Used in Snakepit.Config.
Default: same as pool_startup_batch_size/0
@spec config_default_threads_per_worker() :: pos_integer()
Default threads per worker for thread profile.
Used in Snakepit.Config.
Default: 10
@spec crash_barrier_backoff_ms() :: [pos_integer()]
Default backoff sequence for crash barrier retries.
Used in Snakepit.CrashBarrier.
Default: [50, 100, 200]
@spec crash_barrier_checkout_timeout() :: timeout()
Timeout for checking out worker during crash barrier retry.
Used in Snakepit.Pool crash barrier retry logic.
Default: 5_000 ms (5 seconds)
@spec crash_barrier_max_restarts() :: pos_integer()
Default max restarts for crash barrier retry.
Used in Snakepit.CrashBarrier.
Default: 1
@spec crash_barrier_taint_duration_ms() :: pos_integer()
Default taint duration for crashed workers.
Used in Snakepit.CrashBarrier.
Default: 60_000 ms (1 minute)
@spec default_affinity_mode() :: :hint | :strict_queue | :strict_fail_fast
Default session affinity mode for pools.
:hint- Prefer the last worker when available, otherwise fall back:strict_queue- Queue when preferred worker is busy:strict_fail_fast- Return{:error, :worker_busy}when preferred worker is busy
Default: :hint
@spec default_capacity_strategy() :: :pool | :profile | :hybrid
Default capacity strategy.
Used in Snakepit.Config.
Default: :pool
@spec default_command_timeout() :: timeout()
Default command timeout for worker execute operations.
Used in Snakepit.Pool for command timeout calculation.
When not explicitly configured, derives from rpc_timeout(default_timeout()) based on the
current timeout profile.
Default: derived from profile (rpc_timeout of default_timeout)
@spec default_pool_size() :: pos_integer()
Default pool size based on system schedulers. Used when no explicit pool_size is configured.
Default: System.schedulers_online() * 2
@spec default_timeout() :: timeout()
Returns the default timeout for regular execute operations based on the current profile.
This is the primary user-facing timeout API. Legacy getters derive from this value when not explicitly configured.
@spec default_worker_profile() :: :process | :thread
Default worker profile.
Used in Snakepit.Config.
Default: :process
@spec executor_batch_timeout() :: timeout()
Default timeout for batch operations in Executor.
Used in Snakepit.Executor.execute_batch/2.
Default: 30_000 ms (30 seconds)
@spec graceful_shutdown_timeout_ms() :: pos_integer()
Graceful shutdown timeout for Python process termination. Must be >= Python's shutdown envelope: server.stop(2s) + wait_for_termination(3s) = 5s.
Default: 6_000 ms (6 seconds)
@spec grpc_batch_inference_timeout() :: timeout()
Timeout for batch inference commands.
Used in Snakepit.Adapters.GRPCPython for batch inference operations.
Default: 300_000 ms (5 minutes)
@spec grpc_client_execute_timeout() :: timeout()
Default timeout for gRPC client execute calls.
Used in Snakepit.GRPC.Client.
Default: derived from grpc_command_timeout/0
@spec grpc_command_timeout() :: timeout()
Default command timeout for gRPC adapter.
Used in Snakepit.Adapters.GRPCPython for default command timeouts.
When not explicitly configured, derives from rpc_timeout(default_timeout()) based on the
current timeout profile.
Default: derived from profile (rpc_timeout of default_timeout)
@spec grpc_internal_host() :: String.t()
Default host for internal-only gRPC listeners.
Used when grpc_listener.mode is :internal.
Default: "127.0.0.1"
@spec grpc_large_dataset_timeout() :: timeout()
Timeout for large dataset processing commands.
Used in Snakepit.Adapters.GRPCPython for large dataset processing operations.
Default: 600_000 ms (10 minutes)
@spec grpc_listener_port_check_interval_ms() :: pos_integer()
Interval (ms) between port readiness checks when reusing an existing gRPC listener.
Default: 25 ms
@spec grpc_listener_ready_timeout_ms() :: pos_integer()
Timeout for waiting on the gRPC listener to publish its assigned port.
Default: 5_000 ms
@spec grpc_listener_reuse_attempts() :: pos_integer()
Number of attempts to reuse or rebind a gRPC listener before failing.
Default: 3
@spec grpc_listener_reuse_retry_delay_ms() :: pos_integer()
Delay (ms) between gRPC listener reuse retries.
Default: 100 ms
@spec grpc_listener_reuse_wait_timeout_ms() :: pos_integer()
Max wait (ms) for an already-started gRPC listener to publish its port before retrying.
Default: 500 ms
@spec grpc_max_connections() :: pos_integer()
Default maximum connections for gRPC server.
Used in Snakepit.Application.
Default: 1000
@spec grpc_num_acceptors() :: pos_integer()
Default number of acceptors for gRPC server.
Used in Snakepit.Application.
Default: 20
@spec grpc_port() :: pos_integer()
Default gRPC port for Elixir server.
Legacy: used when grpc_listener is not configured.
Default: 50_051
@spec grpc_port_pool_size() :: pos_integer()
Default port pool size for external pooled listeners.
Used when grpc_listener.mode is :external_pool.
Default: 32
@spec grpc_server_ready_timeout() :: timeout()
Timeout for waiting for gRPC server to become ready.
Used in Snakepit.GRPCWorker during initialization.
Default: 30_000 ms (30 seconds)
@spec grpc_socket_backlog() :: pos_integer()
Default socket backlog for gRPC server.
Used in Snakepit.Application.
Default: 512
@spec grpc_stream_control_timeout_ms() :: pos_integer()
Timeout for sending telemetry control messages to Python workers.
Used in Snakepit.Telemetry.GrpcStream.
Default: 2_000 ms
@spec grpc_stream_open_timeout_ms() :: pos_integer()
Timeout for opening telemetry streams to Python workers.
Used in Snakepit.Telemetry.GrpcStream.
Default: 5_000 ms
@spec grpc_worker_execute_timeout() :: timeout()
Default timeout for GRPCWorker execute calls.
Used in Snakepit.GRPCWorker.execute/4.
When not explicitly configured, derives from rpc_timeout(default_timeout()) based on the
current timeout profile.
Default: derived from profile (rpc_timeout of default_timeout)
@spec grpc_worker_health_check_interval() :: pos_integer()
Interval for health checks in GRPCWorker.
Used in Snakepit.GRPCWorker for periodic health check scheduling.
Default: 30_000 ms (30 seconds)
@spec grpc_worker_health_check_timeout_ms() :: pos_integer()
Timeout for periodic GRPCWorker health-check RPCs.
Used in Snakepit.GRPCWorker when issuing Client.health/3.
Default: 5_000 ms (5 seconds)
@spec grpc_worker_stream_timeout() :: timeout()
Default timeout for GRPCWorker streaming calls.
Used in Snakepit.GRPCWorker.execute_stream/5.
Default: derived from stream_timeout/0
@spec health_monitor_check_interval() :: pos_integer()
Default interval for health monitor cleanup.
Used in Snakepit.HealthMonitor.
Default: 30_000 ms (30 seconds)
@spec health_monitor_crash_window_ms() :: pos_integer()
Default crash window for health monitor. Rolling window for crash counting.
Default: 60_000 ms (1 minute)
@spec health_monitor_max_crashes() :: pos_integer()
Default max crashes before pool is considered unhealthy.
Used in Snakepit.HealthMonitor.
Default: 10
@spec heartbeat_initial_delay_ms() :: non_neg_integer()
Initial delay before starting heartbeat monitoring.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default: 0 ms
@spec heartbeat_max_missed() :: pos_integer()
Maximum missed heartbeats before worker is considered unhealthy.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default: 3
@spec heartbeat_ping_interval_ms() :: pos_integer()
Default heartbeat ping interval.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default: 2_000 ms (2 seconds)
@spec heartbeat_timeout_ms() :: pos_integer()
Default heartbeat timeout.
Used in Snakepit.GRPCWorker heartbeat configuration.
Default: 10_000 ms (10 seconds)
@spec instance_token() :: String.t() | nil
Default instance token for runtime isolation.
Default: nil
@spec lifecycle_check_interval() :: pos_integer()
Default interval for lifecycle checks.
Used in Snakepit.Worker.LifecycleManager.
Default: 60_000 ms (1 minute)
@spec lifecycle_check_max_concurrency() :: pos_integer()
Maximum concurrent workers evaluated during each lifecycle check cycle.
Used in Snakepit.Worker.LifecycleManager.
Default: 8
@spec lifecycle_health_check_interval() :: pos_integer()
Default interval for health checks in lifecycle manager.
Used in Snakepit.Worker.LifecycleManager.
Default: 300_000 ms (5 minutes)
@spec lifecycle_worker_action_timeout_ms() :: pos_integer()
Timeout (ms) per worker action during lifecycle check tasks.
Used in Snakepit.Worker.LifecycleManager.
Default: 2_000 ms
@spec pool_await_ready_timeout() :: timeout()
Default timeout for awaiting pool readiness.
Used in Snakepit.Pool.await_ready/2.
Default: 15_000 ms (15 seconds)
@spec pool_cancelled_retention_multiplier() :: pos_integer()
Multiplier for cancelled request retention time. Retention time = queue_timeout * this multiplier.
Default: 4
@spec pool_max_cancelled_entries() :: pos_integer()
Maximum number of cancelled request entries to track.
Used in Snakepit.Pool for cancelled request management.
Default: 1024
@spec pool_max_queue_size() :: pos_integer()
Maximum queue size for pending requests.
Used in Snakepit.Pool for queue management.
Default: 1000
@spec pool_max_workers() :: pos_integer()
Maximum number of workers allowed per pool.
Used in Snakepit.Pool for worker limit enforcement.
Default: 150
@spec pool_queue_timeout() :: timeout()
Default timeout for queued requests.
Used in Snakepit.Pool for queue management.
When not explicitly configured, derives from queue_timeout/0 based on the
current timeout profile.
Default: derived from profile (10_000 ms for :balanced)
@spec pool_reconcile_batch_size() :: pos_integer()
@spec pool_reconcile_interval_ms() :: non_neg_integer()
@spec pool_reply_margin_ms() :: pos_integer()
Margin reserved for pool reply overhead.
This is subtracted from the total timeout budget to derive the RPC timeout.
Default: 200 ms
@spec pool_request_timeout() :: timeout()
Default timeout for pool execute calls.
Used in Snakepit.Pool.execute/3.
When not explicitly configured, derives from default_timeout/0 based on the
current timeout profile.
Default: derived from profile (300_000 ms for :balanced)
@spec pool_startup_batch_delay_ms() :: non_neg_integer()
Delay between worker startup batches in milliseconds.
Used in Snakepit.Pool for batched startup.
Default: 500 ms
@spec pool_startup_batch_size() :: pos_integer()
Number of workers to start per batch during pool initialization.
Used in Snakepit.Pool for batched startup.
Default: 10
@spec pool_startup_timeout() :: timeout()
Default timeout for worker startup. Used in pool initialization.
Default: 10_000 ms (10 seconds)
@spec pool_streaming_timeout() :: timeout()
Default timeout for pool streaming calls.
Used in Snakepit.Pool.execute_stream/4.
When not explicitly configured, derives from stream_timeout/0 based on the
current timeout profile.
Default: derived from profile (900_000 ms for :balanced)
@spec process_group_kill_enabled?() :: boolean()
Whether process-group based termination is enabled. Used in cleanup and worker shutdown paths.
Default: true
@spec process_registry_cleanup_interval() :: pos_integer()
Default cleanup interval for process registry.
Used in Snakepit.Pool.ProcessRegistry.
Default: 30_000 ms (30 seconds)
@spec process_registry_dets_flush_interval_ms() :: pos_integer()
Interval (ms) for batching DETS fsync operations in Snakepit.Pool.ProcessRegistry.
Default: 25 ms
@spec process_registry_unregister_cleanup_attempts() :: pos_integer()
Maximum attempts to retry unregister cleanup.
Used in Snakepit.Pool.ProcessRegistry.
Default: 10
@spec process_registry_unregister_cleanup_delay() :: pos_integer()
Delay before retrying unregister when external process is still alive.
Used in Snakepit.Pool.ProcessRegistry.
Default: 500 ms
@spec queue_timeout() :: timeout()
Returns the default queue timeout based on the current profile.
@spec retry_backoff_multiplier() :: float()
Default backoff multiplier for exponential backoff.
Used in Snakepit.RetryPolicy.
Default: 2.0
@spec retry_backoff_sequence() :: [pos_integer()]
Default backoff sequence for retries.
Used in Snakepit.RetryPolicy.
Default: [100, 200, 400, 800, 1600]
@spec retry_base_backoff_ms() :: pos_integer()
Default base backoff for retry calculations.
Used in Snakepit.RetryPolicy.
Default: 100 ms
@spec retry_jitter_factor() :: float()
Default jitter factor for retry delays.
Used in Snakepit.RetryPolicy.
Default: 0.25 (25%)
@spec retry_max_attempts() :: pos_integer()
Default maximum retry attempts.
Used in Snakepit.RetryPolicy.
Default: 3
@spec retry_max_backoff_ms() :: pos_integer()
Default maximum backoff delay.
Used in Snakepit.RetryPolicy.
Default: 30_000 ms (30 seconds)
@spec rogue_cleanup_defaults() :: map()
Default rogue cleanup configuration.
Used in Snakepit.Pool.ProcessRegistry.
@spec rogue_cleanup_run_markers() :: [String.t()]
Default command markers used to identify run ids for rogue cleanup.
@spec rogue_cleanup_scripts() :: [String.t()]
Default script names considered for rogue cleanup process matching.
Derives the RPC (inner) timeout from the total timeout budget.
Formula: rpc_timeout = total_timeout - worker_call_margin_ms - pool_reply_margin_ms
This ensures inner timeouts expire before outer GenServer.call timeouts, producing structured error returns instead of unhandled exits.
Examples
iex> Snakepit.Defaults.rpc_timeout(60_000)
58_800 # 60_000 - 1000 - 200
iex> Snakepit.Defaults.rpc_timeout(:infinity)
:infinity
@spec session_cleanup_interval() :: pos_integer()
Default cleanup interval for expired sessions.
Used in Snakepit.Bridge.SessionStore.
Default: 60_000 ms (1 minute)
@spec session_default_ttl() :: pos_integer()
Default TTL for sessions in seconds.
Used in Snakepit.Bridge.SessionStore.
Default: 3600 seconds (1 hour)
@spec session_max_sessions() :: pos_integer() | :infinity
Default maximum number of sessions.
Used in Snakepit.Bridge.SessionStore.
Default: 10_000
@spec session_warning_threshold() :: float()
Session warning threshold as a fraction of max_sessions. When session count exceeds this percentage, warnings are emitted.
Default: 0.8 (80%)
@spec shutdown_margin_ms() :: pos_integer()
Margin added to graceful_shutdown_timeout for supervisor shutdown. This gives the worker time to complete its terminate/2 callback.
Default: 2_000 ms (2 seconds)
@spec stream_timeout() :: timeout()
Returns the default timeout for streaming operations based on the current profile.
@spec timeout_profile() :: atom()
Returns the currently configured timeout profile.
Defaults to :balanced if not configured.
Returns all available timeout profiles.
Each profile contains default_timeout, stream_timeout, and queue_timeout values.
@spec worker_call_margin_ms() :: pos_integer()
Margin reserved for GenServer.call overhead when routing to workers.
This is subtracted from the total timeout budget to derive the RPC timeout.
Default: 1000 ms
@spec worker_ready_timeout() :: timeout()
Timeout for worker ready notification to pool.
Used in Snakepit.GRPCWorker when notifying pool of readiness.
Default: 30_000 ms (30 seconds)
@spec worker_starter_max_restarts() :: non_neg_integer()
@spec worker_starter_max_seconds() :: pos_integer()
@spec worker_supervisor_cleanup_max_retries() :: pos_integer()
Maximum retries while waiting for worker external resource cleanup.
Used in Snakepit.Pool.WorkerSupervisor.
Default: 20
@spec worker_supervisor_cleanup_retry_interval_ms() :: pos_integer()
Retry interval in milliseconds while polling for worker external resource cleanup.
Used in Snakepit.Pool.WorkerSupervisor.
Default: 50 ms
@spec worker_supervisor_max_restarts() :: non_neg_integer()
@spec worker_supervisor_max_seconds() :: pos_integer()