2024-07-22 12:42:30 +08:00
|
|
|
[nats]
|
|
|
|
|
url = "nats://localhost:4222"
|
2025-11-21 09:59:47 +08:00
|
|
|
# mode: "jetstream" (required - only JetStream mode is supported)
|
|
|
|
|
# JetStream provides:
|
2025-11-17 16:25:23 +08:00
|
|
|
# * Message persistence and replay capability
|
|
|
|
|
# * ACK/NAK mechanism for guaranteed delivery
|
|
|
|
|
# * Automatic retry with configurable backoff
|
|
|
|
|
# * Dead-letter queue (DLQ) support
|
|
|
|
|
# * Batch processing and consumer monitoring
|
2025-11-19 16:49:53 +08:00
|
|
|
mode = "jetstream"
|
2024-07-22 12:42:30 +08:00
|
|
|
client = "serial-client"
|
|
|
|
|
cluster = "tele-cluster"
|
2025-11-14 08:42:26 +08:00
|
|
|
stream = "TELEGRAM"
|
|
|
|
|
consumer = "telegram-consumer"
|
2024-07-22 12:42:30 +08:00
|
|
|
|
2025-11-14 21:42:04 +08:00
|
|
|
[nats.stream_limits]
|
2025-11-21 09:59:47 +08:00
|
|
|
# Stream retention and storage limits
|
2025-11-17 16:25:23 +08:00
|
|
|
# max_msgs: Maximum number of messages to keep in the stream (0 = unlimited)
|
2025-11-14 21:42:04 +08:00
|
|
|
max_msgs = 100000
|
2025-11-17 16:25:23 +08:00
|
|
|
# max_bytes: Maximum total size of messages in bytes (0 = unlimited, 67108864 = 64MB)
|
2025-11-14 21:42:04 +08:00
|
|
|
max_bytes = 67108864
|
2025-11-17 16:25:23 +08:00
|
|
|
# max_age: Maximum age of messages before automatic deletion (e.g., "24h", "7d")
|
2025-11-14 21:42:04 +08:00
|
|
|
max_age = "24h"
|
2025-11-17 16:25:23 +08:00
|
|
|
# discard: What to do when limits are reached: "old" (delete oldest) or "new" (reject new)
|
2025-11-14 21:42:04 +08:00
|
|
|
discard = "old"
|
2025-11-17 16:25:23 +08:00
|
|
|
# storage: "file" (persistent to disk) or "memory" (ephemeral, faster but lost on restart)
|
2025-11-14 21:42:04 +08:00
|
|
|
storage = "file"
|
2025-11-17 16:25:23 +08:00
|
|
|
# replicas: Number of stream replicas for high availability (1 = single node, 3+ for production cluster)
|
2025-11-14 21:42:04 +08:00
|
|
|
replicas = 1
|
|
|
|
|
|
2025-11-15 09:46:29 +08:00
|
|
|
[nats.consumer_rules]
|
2025-11-21 09:59:47 +08:00
|
|
|
# Consumer delivery rules
|
2025-11-17 16:25:23 +08:00
|
|
|
# max_deliver: Maximum number of delivery attempts before giving up (0 = unlimited)
|
2025-11-19 13:07:09 +08:00
|
|
|
max_deliver = 3
|
2025-11-17 16:25:23 +08:00
|
|
|
# ack_wait: Time to wait for ACK before redelivering message (e.g., "30s", "2m")
|
2025-11-14 21:42:04 +08:00
|
|
|
ack_wait = "30s"
|
2025-11-17 16:25:23 +08:00
|
|
|
# max_ack_pending: Maximum number of unacknowledged messages before pausing delivery
|
2025-11-19 13:07:09 +08:00
|
|
|
max_ack_pending = 1000
|
2025-11-14 21:42:04 +08:00
|
|
|
|
2025-11-18 14:15:58 +08:00
|
|
|
[nats.auth]
|
|
|
|
|
# NATS authentication configuration (optional for development)
|
2025-11-19 13:07:09 +08:00
|
|
|
# token: Simple token authentication (uncomment if needed)
|
|
|
|
|
# token = "your-dev-token"
|
|
|
|
|
|
|
|
|
|
# TLS configuration (optional - uncomment for secure connections)
|
|
|
|
|
# tls_enabled = true
|
|
|
|
|
# tls_cert_file = "/path/to/client.crt"
|
|
|
|
|
# tls_key_file = "/path/to/client.key"
|
|
|
|
|
# tls_ca_file = "/path/to/ca.crt"
|
2025-11-18 14:15:58 +08:00
|
|
|
|
2024-07-22 12:42:30 +08:00
|
|
|
[subscription]
|
2025-11-14 21:42:04 +08:00
|
|
|
topic = "telegram.serial"
|
2025-11-15 09:01:24 +08:00
|
|
|
queue_group = "tele-queue"
|
2024-07-22 12:42:30 +08:00
|
|
|
|
2024-08-12 17:47:34 +08:00
|
|
|
[publisher]
|
2025-11-14 21:42:04 +08:00
|
|
|
topic = "telegram.json"
|
2024-08-12 17:47:34 +08:00
|
|
|
|
2024-07-22 12:42:30 +08:00
|
|
|
[timeouts]
|
|
|
|
|
server = "5s"
|
|
|
|
|
reconnect_wait = "5s"
|
|
|
|
|
close = "10s"
|
2024-07-22 16:23:15 +08:00
|
|
|
ack_wait = "5s"
|
|
|
|
|
|
2025-11-14 08:42:26 +08:00
|
|
|
[postgres]
|
2025-11-17 17:53:24 +08:00
|
|
|
url = "postgres://caatsm:caatsm@localhost:5432/aviation?sslmode=disable"
|
2025-11-14 08:42:26 +08:00
|
|
|
max_conns = 10
|
|
|
|
|
min_conns = 2
|
|
|
|
|
|
|
|
|
|
[app]
|
2025-11-21 09:59:47 +08:00
|
|
|
# Batch processing configuration
|
2025-11-17 16:25:23 +08:00
|
|
|
# batch_size: Number of messages to fetch in each batch (JetStream pull batch size)
|
2025-11-14 08:42:26 +08:00
|
|
|
batch_size = 50
|
2025-11-17 16:25:23 +08:00
|
|
|
# batch_timeout: Maximum time to wait when fetching a batch (e.g., "2s")
|
2025-11-14 08:42:26 +08:00
|
|
|
batch_timeout = "2s"
|
2025-11-17 16:25:23 +08:00
|
|
|
# monitor_interval: How often to emit consumer statistics and metrics
|
2025-11-14 21:42:04 +08:00
|
|
|
monitor_interval = "30s"
|
2025-11-14 08:42:26 +08:00
|
|
|
|
|
|
|
|
[log]
|
|
|
|
|
level = "info"
|
2025-11-16 11:38:49 +08:00
|
|
|
format = "console"
|
2025-11-17 12:58:40 +08:00
|
|
|
output = ["stdout", "file"]
|
|
|
|
|
file = "logs/caatsm.log"
|
|
|
|
|
|
|
|
|
|
# File rotation settings
|
|
|
|
|
max_size = 100 # MB
|
|
|
|
|
max_backups = 7 # Keep 7 rotated files
|
|
|
|
|
max_age = 30 # Keep logs for 30 days
|
|
|
|
|
compress = true # Compress old log files
|
|
|
|
|
|
|
|
|
|
# Advanced options
|
|
|
|
|
disable_caller = false
|
|
|
|
|
disable_stacktrace = false
|
|
|
|
|
development = false
|
|
|
|
|
|
|
|
|
|
# Sampling configuration (optional, for high-volume scenarios)
|
|
|
|
|
# [log.sampling]
|
|
|
|
|
# initial = 100 # Log first 100 messages
|
|
|
|
|
# thereafter = 100 # Then log every 100th message
|
|
|
|
|
# tick = "1s" # Per second
|
2025-11-14 08:42:26 +08:00
|
|
|
|
2025-11-15 09:01:24 +08:00
|
|
|
[telemetry]
|
2025-11-15 14:42:33 +08:00
|
|
|
enabled = true
|
|
|
|
|
endpoint = "localhost:4318"
|
2025-11-15 16:30:29 +08:00
|
|
|
insecure = true
|
|
|
|
|
|
|
|
|
|
[monitoring]
|
2025-11-16 10:34:53 +08:00
|
|
|
disabled = false
|
2025-11-15 16:30:29 +08:00
|
|
|
addr = ":2112"
|
|
|
|
|
enable_metrics = true
|
|
|
|
|
enable_health = true
|
|
|
|
|
read_timeout = "5s"
|
|
|
|
|
write_timeout = "5s"
|
2025-11-16 09:15:37 +08:00
|
|
|
health_timeout = "2s"
|
|
|
|
|
|
|
|
|
|
[dlq]
|
2025-11-21 09:59:47 +08:00
|
|
|
# Dead-Letter Queue configuration
|
2025-11-17 16:25:23 +08:00
|
|
|
# enabled: Enable DLQ routing for poison messages (messages that fail after max_deliver attempts)
|
2025-11-19 17:09:52 +08:00
|
|
|
enabled = true # Set to true when switching to JetStream mode
|
2025-11-17 16:25:23 +08:00
|
|
|
# subject: NATS subject where failed messages will be published for manual inspection
|
|
|
|
|
subject = "caatsm.dlq"
|