pub struct ServerConfig {Show 41 fields
pub host: String,
pub port: u16,
pub redis_url: String,
pub redis_reader_url: Option<String>,
pub config_file_path: String,
pub api_key: SecretString,
pub rate_limit_requests_per_second: u64,
pub rate_limit_burst_size: u32,
pub metrics_port: u16,
pub enable_swagger: bool,
pub redis_connection_timeout_ms: u64,
pub redis_key_prefix: String,
pub redis_pool_max_size: usize,
pub redis_reader_pool_max_size: usize,
pub redis_pool_timeout_ms: u64,
pub rpc_timeout_ms: u64,
pub provider_max_retries: u8,
pub provider_retry_base_delay_ms: u64,
pub provider_retry_max_delay_ms: u64,
pub provider_max_failovers: u8,
pub provider_failure_threshold: u32,
pub provider_pause_duration_secs: u64,
pub provider_failure_expiration_secs: u64,
pub repository_storage_type: RepositoryStorageType,
pub reset_storage_on_start: bool,
pub storage_encryption_key: Option<SecretString>,
pub transaction_expiration_hours: f64,
pub rpc_allowed_hosts: Vec<String>,
pub rpc_block_private_ips: bool,
pub relayer_concurrency_limit: usize,
pub max_connections: usize,
pub connection_backlog: u32,
pub request_timeout_seconds: u64,
pub stellar_mainnet_fee_forwarder_address: Option<String>,
pub stellar_testnet_fee_forwarder_address: Option<String>,
pub stellar_mainnet_soroswap_router_address: Option<String>,
pub stellar_testnet_soroswap_router_address: Option<String>,
pub stellar_mainnet_soroswap_factory_address: Option<String>,
pub stellar_testnet_soroswap_factory_address: Option<String>,
pub stellar_mainnet_soroswap_native_wrapper_address: Option<String>,
pub stellar_testnet_soroswap_native_wrapper_address: Option<String>,
}Fields§
§host: StringThe host address the server will bind to.
port: u16The port number the server will listen on.
redis_url: StringThe URL for the Redis primary instance (used for write operations).
redis_reader_url: Option<String>Optional URL for Redis reader endpoint (used for read operations).
When set, read operations use this endpoint while writes use redis_url.
Useful for AWS ElastiCache with read replicas.
config_file_path: StringThe file path to the server’s configuration file.
api_key: SecretStringThe API key used for authentication.
rate_limit_requests_per_second: u64The number of requests allowed per second.
rate_limit_burst_size: u32The maximum burst size for rate limiting.
metrics_port: u16The port number for exposing metrics.
enable_swagger: boolEnable Swagger UI.
redis_connection_timeout_ms: u64The number of seconds to wait for a Redis connection.
redis_key_prefix: StringThe prefix for the Redis key.
redis_pool_max_size: usizeMaximum number of connections in the Redis pool.
redis_reader_pool_max_size: usizeMaximum pool size for reader connections. Defaults to 1000. Useful for read-heavy workloads where more reader connections are beneficial.
redis_pool_timeout_ms: u64Timeout in milliseconds waiting to get a connection from the pool.
rpc_timeout_ms: u64The number of milliseconds to wait for an RPC response.
provider_max_retries: u8Maximum number of retry attempts for provider operations.
provider_retry_base_delay_ms: u64Base delay between retry attempts (milliseconds).
provider_retry_max_delay_ms: u64Maximum delay between retry attempts (milliseconds).
provider_max_failovers: u8Maximum number of failovers (switching to different providers).
provider_failure_threshold: u32Number of consecutive failures before pausing a provider.
provider_pause_duration_secs: u64Duration in seconds to pause a provider after reaching failure threshold.
provider_failure_expiration_secs: u64Duration in seconds after which failures are considered stale and reset.
repository_storage_type: RepositoryStorageTypeThe type of repository storage to use.
reset_storage_on_start: boolFlag to force config file processing.
storage_encryption_key: Option<SecretString>The encryption key for the storage.
transaction_expiration_hours: f64Transaction expiration time in hours for transactions in final states. Supports fractional values (e.g., 0.1 = 6 minutes).
rpc_allowed_hosts: Vec<String>Comma-separated list of allowed RPC hosts (domains or IPs). If non-empty, only these hosts are permitted.
rpc_block_private_ips: boolIf true, block private IP addresses (RFC 1918, loopback, link-local). Cloud metadata endpoints are always blocked.
relayer_concurrency_limit: usizeMaximum number of concurrent requests allowed for /api/v1/relayers/* endpoints.
max_connections: usizeMaximum number of concurrent TCP connections server-wide.
connection_backlog: u32TCP listen connection backlog size (pending connections queue). Higher values allow more connections to be queued during traffic bursts.
request_timeout_seconds: u64Request handler timeout in seconds for API endpoints.
stellar_mainnet_fee_forwarder_address: Option<String>Stellar mainnet FeeForwarder contract address for gas abstraction.
stellar_testnet_fee_forwarder_address: Option<String>Stellar testnet FeeForwarder contract address for gas abstraction.
stellar_mainnet_soroswap_router_address: Option<String>Stellar mainnet Soroswap router contract address.
stellar_testnet_soroswap_router_address: Option<String>Stellar testnet Soroswap router contract address.
stellar_mainnet_soroswap_factory_address: Option<String>Stellar mainnet Soroswap factory contract address.
stellar_testnet_soroswap_factory_address: Option<String>Stellar testnet Soroswap factory contract address.
stellar_mainnet_soroswap_native_wrapper_address: Option<String>Stellar mainnet native XLM wrapper token address for Soroswap.
stellar_testnet_soroswap_native_wrapper_address: Option<String>Stellar testnet native XLM wrapper token address for Soroswap.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a new ServerConfig instance from environment variables.
§Panics
This function will panic if the REDIS_URL or API_KEY environment
variables are not set, as they are required for the server to function.
§Defaults
HOSTdefaults to"0.0.0.0".APP_PORTdefaults to8080.CONFIG_DIRdefaults to"config/config.json".RATE_LIMIT_REQUESTS_PER_SECONDdefaults to100.RATE_LIMIT_BURST_SIZEdefaults to300.METRICS_PORTdefaults to8081.PROVIDER_MAX_RETRIESdefaults to3.PROVIDER_RETRY_BASE_DELAY_MSdefaults to100.PROVIDER_RETRY_MAX_DELAY_MSdefaults to2000.PROVIDER_MAX_FAILOVERSdefaults to3.PROVIDER_FAILURE_THRESHOLDdefaults to3.PROVIDER_PAUSE_DURATION_SECSdefaults to60(1 minute).PROVIDER_FAILURE_EXPIRATION_SECSdefaults to60(1 minute).REPOSITORY_STORAGE_TYPEdefaults to"in_memory".TRANSACTION_EXPIRATION_HOURSdefaults to4.REQUEST_TIMEOUT_SECONDSdefaults to30(security measure for DoS protection).CONNECTION_BACKLOGdefaults to511(production-ready value for traffic bursts).
Sourcepub fn get_redis_url() -> String
pub fn get_redis_url() -> String
Gets the Redis URL from environment variable (panics if not set)
Sourcepub fn get_redis_url_optional() -> Option<String>
pub fn get_redis_url_optional() -> Option<String>
Gets the Redis URL from environment variable or returns None if not set
Sourcepub fn get_redis_reader_url_optional() -> Option<String>
pub fn get_redis_reader_url_optional() -> Option<String>
Gets the Redis reader URL from environment variable or returns None if not set. When set, read operations will use this endpoint while writes use REDIS_URL. Useful for AWS ElastiCache with read replicas.
Sourcepub fn get_config_file_path() -> String
pub fn get_config_file_path() -> String
Gets the config file path from environment variables or default
Sourcepub fn get_queue_backend() -> String
pub fn get_queue_backend() -> String
Gets the queue backend from environment variable or default.
Supported values: “redis”, “sqs” Defaults to “redis” when not set.
Sourcepub fn get_sqs_queue_type() -> String
pub fn get_sqs_queue_type() -> String
Gets the SQS queue type from environment variable or default.
Supported values: “auto” (default), “standard”, “fifo”
auto: auto-detect by probing queues at startupstandard/fifo: skip probing, use the specified type directly
Sourcepub fn get_aws_region() -> Result<String, String>
pub fn get_aws_region() -> Result<String, String>
Gets the AWS region from environment variable.
Required when using SQS queue backend.
§Errors
Returns error if AWS_REGION is not set.
Sourcepub fn get_aws_account_id() -> Result<String, String>
pub fn get_aws_account_id() -> Result<String, String>
Gets the AWS account ID from environment variable.
Required when using SQS queue backend and SQS_QUEUE_URL_PREFIX is not provided.
§Errors
Returns error if AWS_ACCOUNT_ID is not set.
Sourcepub fn get_api_key() -> SecretString
pub fn get_api_key() -> SecretString
Gets the API key from environment variable (panics if not set or too short)
Sourcepub fn get_api_key_optional() -> Option<SecretString>
pub fn get_api_key_optional() -> Option<SecretString>
Gets the API key from environment variable or returns None if not set or invalid
Sourcepub fn get_rate_limit_requests_per_second() -> u64
pub fn get_rate_limit_requests_per_second() -> u64
Gets the rate limit requests per second from environment variable or default
Sourcepub fn get_rate_limit_burst_size() -> u32
pub fn get_rate_limit_burst_size() -> u32
Gets the rate limit burst size from environment variable or default
Sourcepub fn get_metrics_port() -> u16
pub fn get_metrics_port() -> u16
Gets the metrics port from environment variable or default
Sourcepub fn get_enable_swagger() -> bool
pub fn get_enable_swagger() -> bool
Gets the enable swagger setting from environment variable or default
Sourcepub fn get_redis_connection_timeout_ms() -> u64
pub fn get_redis_connection_timeout_ms() -> u64
Gets the Redis connection timeout from environment variable or default
Sourcepub fn get_redis_key_prefix() -> String
pub fn get_redis_key_prefix() -> String
Gets the Redis key prefix from environment variable or default
Sourcepub fn get_redis_pool_max_size() -> usize
pub fn get_redis_pool_max_size() -> usize
Gets the Redis pool max size from environment variable or default Returns default (500) if value is 0 or invalid
Sourcepub fn get_redis_reader_pool_max_size() -> usize
pub fn get_redis_reader_pool_max_size() -> usize
Gets the Redis reader pool max size from environment variable. Returns 1000 if not set or invalid.
Sourcepub fn get_redis_pool_timeout_ms() -> u64
pub fn get_redis_pool_timeout_ms() -> u64
Gets the Redis pool timeout from environment variable or default Returns default (10000) if value is 0 or invalid
Sourcepub fn get_rpc_timeout_ms() -> u64
pub fn get_rpc_timeout_ms() -> u64
Gets the RPC timeout from environment variable or default
Sourcepub fn get_provider_max_retries() -> u8
pub fn get_provider_max_retries() -> u8
Gets the provider max retries from environment variable or default
Sourcepub fn get_provider_retry_base_delay_ms() -> u64
pub fn get_provider_retry_base_delay_ms() -> u64
Gets the provider retry base delay from environment variable or default
Sourcepub fn get_provider_retry_max_delay_ms() -> u64
pub fn get_provider_retry_max_delay_ms() -> u64
Gets the provider retry max delay from environment variable or default
Sourcepub fn get_provider_max_failovers() -> u8
pub fn get_provider_max_failovers() -> u8
Gets the provider max failovers from environment variable or default
Sourcepub fn get_provider_failure_threshold() -> u32
pub fn get_provider_failure_threshold() -> u32
Gets the provider failure threshold from environment variable or default
Sourcepub fn get_provider_pause_duration_secs() -> u64
pub fn get_provider_pause_duration_secs() -> u64
Gets the provider pause duration in seconds from environment variable or default
Defaults to 60 seconds (1 minute) for faster recovery while still providing a reasonable cooldown period for failed providers.
Sourcepub fn get_provider_failure_expiration_secs() -> u64
pub fn get_provider_failure_expiration_secs() -> u64
Gets the provider failure expiration duration in seconds from environment variable or default
Defaults to 60 seconds (1 minute). Failures older than this are considered stale and reset, allowing providers to naturally recover over time.
Sourcepub fn get_repository_storage_type() -> RepositoryStorageType
pub fn get_repository_storage_type() -> RepositoryStorageType
Gets the repository storage type from environment variable or default
Sourcepub fn get_reset_storage_on_start() -> bool
pub fn get_reset_storage_on_start() -> bool
Gets the reset storage on start setting from environment variable or default
Sourcepub fn get_storage_encryption_key() -> Option<SecretString>
pub fn get_storage_encryption_key() -> Option<SecretString>
Gets the storage encryption key from environment variable or None
Sourcepub fn get_transaction_expiration_hours() -> f64
pub fn get_transaction_expiration_hours() -> f64
Gets the transaction expiration hours from environment variable or default Supports fractional values (e.g., 0.1 = 6 minutes).
Sourcepub fn get_rpc_allowed_hosts() -> Vec<String>
pub fn get_rpc_allowed_hosts() -> Vec<String>
Gets the allowed RPC hosts from environment variable or default (empty list)
Sourcepub fn get_rpc_block_private_ips() -> bool
pub fn get_rpc_block_private_ips() -> bool
Gets the block private IPs setting from environment variable or default (false)
Sourcepub fn get_relayer_concurrency_limit() -> usize
pub fn get_relayer_concurrency_limit() -> usize
Gets the relayer concurrency limit from environment variable or default (100)
Sourcepub fn get_max_connections() -> usize
pub fn get_max_connections() -> usize
Gets the max connections from environment variable or default (256)
Sourcepub fn get_connection_backlog() -> u32
pub fn get_connection_backlog() -> u32
Gets the connection backlog from environment variable or default (511)
TCP listen backlog controls the size of the queue for pending connections. Higher values allow more connections to be queued during traffic bursts, preventing connection drops. Default of 511.
Sourcepub fn get_request_timeout_seconds() -> u64
pub fn get_request_timeout_seconds() -> u64
Gets the request timeout in seconds from environment variable or default (30)
This is a security measure to prevent resource exhaustion attacks (DoS). It limits how long a request handler can run, preventing slowloris-style attacks and ensuring resources are freed promptly.
Sourcepub fn get_distributed_mode() -> bool
pub fn get_distributed_mode() -> bool
Gets whether distributed mode is enabled from the DISTRIBUTED_MODE environment variable.
When true, distributed locks are used to coordinate across multiple instances
(e.g., preventing duplicate cron execution in multi-instance deployments).
When false (default), locks are skipped — appropriate for single-instance deployments.
Defaults to false.
pub fn get_stellar_mainnet_fee_forwarder_address() -> Option<String>
pub fn get_stellar_testnet_fee_forwarder_address() -> Option<String>
pub fn get_stellar_mainnet_soroswap_router_address() -> Option<String>
pub fn get_stellar_testnet_soroswap_router_address() -> Option<String>
pub fn get_stellar_mainnet_soroswap_factory_address() -> Option<String>
pub fn get_stellar_testnet_soroswap_factory_address() -> Option<String>
pub fn get_stellar_mainnet_soroswap_native_wrapper_address() -> Option<String>
pub fn get_stellar_testnet_soroswap_native_wrapper_address() -> Option<String>
Sourcepub fn resolve_stellar_fee_forwarder_address(is_testnet: bool) -> Option<String>
pub fn resolve_stellar_fee_forwarder_address(is_testnet: bool) -> Option<String>
Resolves the FeeForwarder contract address for the given network.
Sourcepub fn resolve_stellar_soroswap_router_address(
is_testnet: bool,
) -> Option<String>
pub fn resolve_stellar_soroswap_router_address( is_testnet: bool, ) -> Option<String>
Resolves the Soroswap router contract address for the given network.
Sourcepub fn resolve_stellar_soroswap_factory_address(
is_testnet: bool,
) -> Option<String>
pub fn resolve_stellar_soroswap_factory_address( is_testnet: bool, ) -> Option<String>
Resolves the Soroswap factory contract address for the given network.
Sourcepub fn resolve_stellar_soroswap_native_wrapper_address(
is_testnet: bool,
) -> Option<String>
pub fn resolve_stellar_soroswap_native_wrapper_address( is_testnet: bool, ) -> Option<String>
Resolves the Soroswap native wrapper token address for the given network.
Sourcepub fn get_worker_concurrency(worker_name: &str, default: usize) -> usize
pub fn get_worker_concurrency(worker_name: &str, default: usize) -> usize
Get worker concurrency from environment variable or use default
Environment variable format: BACKGROUND_WORKER_{WORKER_NAME}_CONCURRENCY
Example: BACKGROUND_WORKER_TRANSACTION_REQUEST_CONCURRENCY=20
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnwindSafe for ServerConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more