Documentation
¶
Index ¶
- Constants
- Variables
- func InitConfig(configFile string) error
- func MockConfig(mockConfig *Configuration)
- type AccountGenerationHttpService
- type AccountNumberGenerationConfig
- type Configuration
- type DataSourceConfig
- type HashChainConfig
- type Notification
- type QueueConfig
- type RateLimitConfig
- type ReconciliationConfig
- type RedisConfig
- type ServerConfig
- type SlackWebhook
- type TransactionConfig
- type TypeSenseConfig
- type WebhookConfig
Constants ¶
const ( DEFAULT_PORT = "5001" DEFAULT_CLEANUP_SEC = 10800 // 3 hours in seconds DEFAULT_TYPESENSE_KEY = "ledgerforge-api-key" DEFAULT_MONITORING_PORT = "5004" DEFAULT_MAX_UPLOAD_SIZE_MB = 256 // caps reconciliation file uploads // DEFAULT_MAX_REQUEST_BODY_SIZE_MB caps non-upload request bodies so a large // POST can't exhaust memory before a handler (or the auth middleware) reads it. DEFAULT_MAX_REQUEST_BODY_SIZE_MB = 5 // DEFAULT_UPLOAD_URL_TIMEOUT_SEC caps how long a URL-based reconciliation // upload may spend fetching the remote body, preventing a slow or stalled // upstream from hanging the handler. DEFAULT_UPLOAD_URL_TIMEOUT_SEC = 30 )
Default constants
Variables ¶
var ConfigStore atomic.Value
Functions ¶
func InitConfig ¶
func MockConfig ¶
func MockConfig(mockConfig *Configuration)
MockConfig sets a mock configuration for testing purposes.
Types ¶
type AccountNumberGenerationConfig ¶
type AccountNumberGenerationConfig struct {
EnableAutoGeneration bool `json:"enable_auto_generation"`
HttpService AccountGenerationHttpService `json:"http_service"`
}
type Configuration ¶
type Configuration struct {
ProjectName string `json:"project_name" envconfig:"LEDGERFORGE_PROJECT_NAME"`
BackupDir string `json:"backup_dir" envconfig:"LEDGERFORGE_BACKUP_DIR"`
AwsAccessKeyId string `json:"aws_access_key_id" envconfig:"LEDGERFORGE_AWS_ACCESS_KEY_ID"`
S3Endpoint string `json:"s3_endpoint" envconfig:"LEDGERFORGE_S3_ENDPOINT"`
AwsSecretAccessKey string `json:"aws_secret_access_key" envconfig:"LEDGERFORGE_AWS_SECRET_ACCESS_KEY"`
S3BucketName string `json:"s3_bucket_name" envconfig:"LEDGERFORGE_S3_BUCKET_NAME"`
S3Region string `json:"s3_region" envconfig:"LEDGERFORGE_S3_REGION"`
Server ServerConfig `json:"server"`
DataSource DataSourceConfig `json:"data_source"`
Redis RedisConfig `json:"redis"`
TypeSense TypeSenseConfig `json:"typesense"`
TypeSenseKey string `json:"type_sense_key" envconfig:"LEDGERFORGE_TYPESENSE_KEY"`
TokenizationSecret string `json:"tokenization_secret" envconfig:"LEDGERFORGE_TOKENIZATION_SECRET"`
AccountNumberGeneration AccountNumberGenerationConfig `json:"account_number_generation"`
Notification Notification `json:"notification"`
RateLimit RateLimitConfig `json:"rate_limit"`
EnableTelemetry bool `json:"enable_telemetry" envconfig:"LEDGERFORGE_ENABLE_TELEMETRY"`
TelemetryKey string `json:"telemetry_key" envconfig:"LEDGERFORGE_TELEMETRY_KEY"`
TelemetryEndpoint string `json:"telemetry_endpoint" envconfig:"LEDGERFORGE_TELEMETRY_ENDPOINT"`
EnableObservability bool `json:"enable_observability" envconfig:"LEDGERFORGE_ENABLE_OBSERVABILITY"`
MonitoringDSN string `json:"monitoring_dsn" envconfig:"LEDGERFORGE_MONITORING_DSN"`
Transaction TransactionConfig `json:"transaction"`
Reconciliation ReconciliationConfig `json:"reconciliation"`
Queue QueueConfig `json:"queue"`
}
func Fetch ¶
func Fetch() (*Configuration, error)
func (*Configuration) RemoteMonitoringDSN ¶
func (cnf *Configuration) RemoteMonitoringDSN() string
func (*Configuration) UploadDomainWhitelistHosts ¶
func (cnf *Configuration) UploadDomainWhitelistHosts() []string
UploadDomainWhitelistHosts returns the parsed, trimmed, de-duplicated, lowercase list of exact hostnames permitted as targets for URL-based reconciliation uploads. Entries may be supplied as bare hostnames ("example.com") or full URLs ("https://example.com/path"); the hostname is extracted either way. An empty/unset whitelist yields an empty slice, which the upload handler treats as deny-by-default.
func (*Configuration) WebhookSigningSecret ¶
func (cnf *Configuration) WebhookSigningSecret() string
WebhookSigningSecret selects the dedicated secret before the legacy API secret.
type DataSourceConfig ¶
type DataSourceConfig struct {
Dns string `json:"dns" envconfig:"LEDGERFORGE_DATA_SOURCE_DNS"`
MaxOpenConns int `json:"max_open_conns" envconfig:"LEDGERFORGE_DATABASE_MAX_OPEN_CONNS"`
MaxIdleConns int `json:"max_idle_conns" envconfig:"LEDGERFORGE_DATABASE_MAX_IDLE_CONNS"`
ConnMaxLifetime time.Duration `json:"conn_max_lifetime" envconfig:"LEDGERFORGE_DATABASE_CONN_MAX_LIFETIME"`
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time" envconfig:"LEDGERFORGE_DATABASE_CONN_MAX_IDLE_TIME"`
}
type HashChainConfig ¶
type HashChainConfig struct {
Enabled bool `json:"enabled" envconfig:"LEDGERFORGE_TRANSACTION_HASHCHAIN_ENABLED"`
PollInterval time.Duration `json:"poll_interval" envconfig:"LEDGERFORGE_TRANSACTION_HASHCHAIN_POLL_INTERVAL"`
BatchSize int `json:"batch_size" envconfig:"LEDGERFORGE_TRANSACTION_HASHCHAIN_BATCH_SIZE"`
TrailingDelay time.Duration `json:"trailing_delay" envconfig:"LEDGERFORGE_TRANSACTION_HASHCHAIN_TRAILING_DELAY"`
}
HashChainConfig controls the background hash-chainer that seals transaction history into a tamper-evident chain. It lives under transaction config and is disabled by default.
type Notification ¶
type Notification struct {
Slack SlackWebhook `json:"slack"`
Webhook WebhookConfig `json:"webhook"`
}
type QueueConfig ¶
type QueueConfig struct {
TransactionQueue string `json:"transaction_queue" envconfig:"LEDGERFORGE_QUEUE_TRANSACTION"`
WebhookQueue string `json:"webhook_queue" envconfig:"LEDGERFORGE_QUEUE_WEBHOOK"`
IndexQueue string `json:"index_queue" envconfig:"LEDGERFORGE_QUEUE_INDEX"`
InflightExpiryQueue string `json:"inflight_expiry_queue" envconfig:"LEDGERFORGE_QUEUE_INFLIGHT_EXPIRY"`
InflightCommitQueue string `json:"inflight_commit_queue" envconfig:"LEDGERFORGE_QUEUE_INFLIGHT_COMMIT"`
NumberOfQueues int `json:"number_of_queues" envconfig:"LEDGERFORGE_QUEUE_NUMBER_OF_QUEUES"`
EnableHotLane bool `json:"enable_hot_lane" envconfig:"LEDGERFORGE_QUEUE_ENABLE_HOT_LANE"`
HotQueueName string `json:"hot_queue_name" envconfig:"LEDGERFORGE_QUEUE_HOT_QUEUE_NAME"`
HotQueueConcurrency int `json:"hot_queue_concurrency" envconfig:"LEDGERFORGE_QUEUE_HOT_QUEUE_CONCURRENCY"`
HotPairTTL time.Duration `json:"hot_pair_ttl" envconfig:"LEDGERFORGE_QUEUE_HOT_PAIR_TTL"`
HotPairLockContentionThreshold int `json:"hot_pair_lock_contention_threshold" envconfig:"LEDGERFORGE_QUEUE_HOT_PAIR_LOCK_CONTENTION_THRESHOLD"`
RejectLockContentionImmediately bool `json:"reject_lock_contention_immediately" envconfig:"LEDGERFORGE_QUEUE_REJECT_LOCK_CONTENTION_IMMEDIATELY"`
InsufficientFundRetries bool `json:"insufficient_fund_retries" envconfig:"LEDGERFORGE_QUEUE_INSUFFICIENT_FUND_RETRIES"`
MaxRetryAttempts int `json:"max_retry_attempts" envconfig:"LEDGERFORGE_QUEUE_MAX_RETRY_ATTEMPTS"`
MonitoringPort string `json:"monitoring_port" envconfig:"LEDGERFORGE_QUEUE_MONITORING_PORT"`
WebhookConcurrency int `json:"webhook_concurrency" envconfig:"LEDGERFORGE_QUEUE_WEBHOOK_CONCURRENCY"`
TransactionWorkerConcurrency int `json:"transaction_worker_concurrency" envconfig:"LEDGERFORGE_QUEUE_TRANSACTION_WORKER_CONCURRENCY"`
EnableBackpressure bool `json:"enable_backpressure" envconfig:"LEDGERFORGE_QUEUE_ENABLE_BACKPRESSURE"`
BackpressureMemoryPercent float64 `json:"backpressure_memory_percent" envconfig:"LEDGERFORGE_QUEUE_BACKPRESSURE_MEMORY_PERCENT"`
BackpressureMaxPendingTasks int `json:"backpressure_max_pending_tasks" envconfig:"LEDGERFORGE_QUEUE_BACKPRESSURE_MAX_PENDING_TASKS"`
BackpressureCheckInterval time.Duration `json:"backpressure_check_interval" envconfig:"LEDGERFORGE_QUEUE_BACKPRESSURE_CHECK_INTERVAL"`
}
type RateLimitConfig ¶
type RateLimitConfig struct {
RequestsPerSecond *float64 `json:"requests_per_second" envconfig:"LEDGERFORGE_RATE_LIMIT_RPS"`
Burst *int `json:"burst" envconfig:"LEDGERFORGE_RATE_LIMIT_BURST"`
CleanupIntervalSec *int `json:"cleanup_interval_sec" envconfig:"LEDGERFORGE_RATE_LIMIT_CLEANUP_INTERVAL_SEC"`
}
RateLimitConfig preserves the legacy defaults: 5,000,000 requests/second and a 10,000,000 burst. Deployments should set explicit workload-based limits.
type ReconciliationConfig ¶
type ReconciliationConfig struct {
DefaultStrategy string `json:"default_strategy" envconfig:"LEDGERFORGE_RECONCILIATION_DEFAULT_STRATEGY"`
ProgressInterval int `json:"progress_interval" envconfig:"LEDGERFORGE_RECONCILIATION_PROGRESS_INTERVAL"`
MaxRetries int `json:"max_retries" envconfig:"LEDGERFORGE_RECONCILIATION_MAX_RETRIES"`
RetryDelay time.Duration `json:"retry_delay" envconfig:"LEDGERFORGE_RECONCILIATION_RETRY_DELAY"`
}
type RedisConfig ¶
type RedisConfig struct {
Dns string `json:"dns" envconfig:"LEDGERFORGE_REDIS_DNS"`
SkipTLSVerify bool `json:"skip_tls_verify" envconfig:"LEDGERFORGE_REDIS_SKIP_TLS_VERIFY"`
PoolSize int `json:"pool_size" envconfig:"LEDGERFORGE_REDIS_POOL_SIZE"`
MinIdleConns int `json:"min_idle_conns" envconfig:"LEDGERFORGE_REDIS_MIN_IDLE_CONNS"`
// ConnMaxIdleTime must stay below any server or proxy idle timeout
// (managed Redis/Valkey services commonly use 300s) so pooled connections
// are recycled before the remote end closes them ("write: broken pipe").
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time" envconfig:"LEDGERFORGE_REDIS_CONN_MAX_IDLE_TIME"`
}
type ServerConfig ¶
type ServerConfig struct {
// AllowLegacyAPIKeys enables the bounded compatibility lookup for active
// bcrypt keys without key_prefix. Default true; disable after rotating old keys.
AllowLegacyAPIKeys *bool `json:"allow_legacy_api_keys" envconfig:"LEDGERFORGE_SERVER_ALLOW_LEGACY_API_KEYS"`
SSL bool `json:"ssl" envconfig:"LEDGERFORGE_SERVER_SSL"`
CertStoragePath string `json:"cert_storage_path" envconfig:"LEDGERFORGE_CERT_STORAGE_PATH"`
Secure bool `json:"secure" envconfig:"LEDGERFORGE_SERVER_SECURE"`
SecretKey string `json:"secret_key" envconfig:"LEDGERFORGE_SERVER_SECRET_KEY"`
Domain string `json:"domain" envconfig:"LEDGERFORGE_SERVER_SSL_DOMAIN"`
Email string `json:"ssl_email" envconfig:"LEDGERFORGE_SERVER_SSL_EMAIL"`
Port string `json:"port" envconfig:"LEDGERFORGE_SERVER_PORT"`
MetricsBearerToken string `json:"metrics_bearer_token" envconfig:"LEDGERFORGE_METRICS_BEARER_TOKEN"`
MaxUploadSizeMB int64 `json:"max_upload_size_mb" envconfig:"LEDGERFORGE_SERVER_MAX_UPLOAD_SIZE_MB"`
MaxRequestBodySizeMB int64 `json:"max_request_body_size_mb" envconfig:"LEDGERFORGE_SERVER_MAX_REQUEST_BODY_SIZE_MB"`
// UploadWhitelist is a comma-separated list of exact hostnames permitted as
// targets for URL-based reconciliation uploads (LEDGERFORGE_UPLOAD_DOMAIN_WHITELIST).
// Empty/unset means deny-by-default: every URL upload is rejected. Listing a
// bare IP literal or "localhost" is unsafe and defeats the SSRF guard.
UploadDomainWhitelist string `json:"upload_whitelist" envconfig:"LEDGERFORGE_UPLOAD_DOMAIN_WHITELIST"`
// UploadURLTimeoutSec caps the HTTP GET issued for a URL-based upload
// (LEDGERFORGE_UPLOAD_URL_TIMEOUT_SEC). Defaults to DEFAULT_UPLOAD_URL_TIMEOUT_SEC.
UploadURLTimeoutSec int `json:"upload_url_timeout_sec" envconfig:"LEDGERFORGE_UPLOAD_URL_TIMEOUT_SEC"`
}
type SlackWebhook ¶
type SlackWebhook struct {
WebhookUrl string `json:"webhook_url" envconfig:"LEDGERFORGE_SLACK_WEBHOOK_URL"`
}
type TransactionConfig ¶
type TransactionConfig struct {
BatchSize int `json:"batch_size" envconfig:"LEDGERFORGE_TRANSACTION_BATCH_SIZE"`
MaxQueueSize int `json:"max_queue_size" envconfig:"LEDGERFORGE_TRANSACTION_MAX_QUEUE_SIZE"`
MaxWorkers int `json:"max_workers" envconfig:"LEDGERFORGE_TRANSACTION_MAX_WORKERS"`
LockDuration time.Duration `json:"lock_duration" envconfig:"LEDGERFORGE_TRANSACTION_LOCK_DURATION"`
LockWaitTimeout time.Duration `json:"lock_wait_timeout" envconfig:"LEDGERFORGE_TRANSACTION_LOCK_WAIT_TIMEOUT"`
IndexQueuePrefix string `json:"index_queue_prefix" envconfig:"LEDGERFORGE_TRANSACTION_INDEX_QUEUE_PREFIX"`
EnableCoalescing bool `json:"enable_coalescing" envconfig:"LEDGERFORGE_TRANSACTION_ENABLE_COALESCING"`
EnableQueuedChecks bool `json:"enable_queued_checks" envconfig:"LEDGERFORGE_TRANSACTION_ENABLE_QUEUED_CHECKS"`
DisableBatchReferenceCheck bool `json:"disable_batch_reference_check" envconfig:"LEDGERFORGE_TRANSACTION_DISABLE_BATCH_REFERENCE_CHECK"`
HashChain HashChainConfig `json:"hash_chain"`
}
type TypeSenseConfig ¶
type WebhookConfig ¶
type WebhookConfig struct {
// SigningSecret is shared by notifications and transaction hooks. When unset,
// Server.SecretKey is the legacy fallback. With neither set, delivery is unsigned.
SigningSecret string `json:"signing_secret" envconfig:"LEDGERFORGE_WEBHOOK_SIGNING_SECRET"`
// BlockPrivateDestinations rejects non-global special-purpose and translation
// addresses at registration and connection time. Default false preserves local receivers.
BlockPrivateDestinations bool `json:"block_private_destinations" envconfig:"LEDGERFORGE_WEBHOOK_BLOCK_PRIVATE_DESTINATIONS"`
// TimeoutSec defaults to 30 seconds and is capped at 120 seconds.
TimeoutSec int `json:"timeout_sec" envconfig:"LEDGERFORGE_WEBHOOK_TIMEOUT_SEC"`
Url string `json:"url" envconfig:"LEDGERFORGE_WEBHOOK_URL"`
Headers map[string]string `json:"headers" envconfig:"LEDGERFORGE_WEBHOOK_HEADERS"`
}