Module: Legion::Data::Settings
- Extended by:
- Logging::Helper
- Defined in:
- lib/legion/data/settings.rb
Constant Summary collapse
- CREDS =
{ sqlite: { database: 'legionio.db' }, mysql2: { username: 'legion', password: 'legion', database: 'legionio', host: '127.0.0.1', port: 3306 }, postgres: { user: 'legion', password: 'legion', database: 'legionio', host: '127.0.0.1', port: 5432 } }.freeze
Class Method Summary collapse
- .archival ⇒ Object
- .cache ⇒ Object
- .creds(adapter = nil) ⇒ Object
- .default ⇒ Object
- .local ⇒ Object
- .migrations ⇒ Object
- .models ⇒ Object
Methods included from Logging::Helper
Class Method Details
.archival ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/legion/data/settings.rb', line 141 def self.archival { retention_days: 90, batch_size: 1000, storage_backend: nil } end |
.cache ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/legion/data/settings.rb', line 149 def self.cache { connected: false, auto_enable: Legion::Settings[:cache][:connected], static_cache: false, ttl: 60 } end |
.creds(adapter = nil) ⇒ Object
136 137 138 139 |
# File 'lib/legion/data/settings.rb', line 136 def self.creds(adapter = nil) adapter = (adapter || :sqlite).to_sym CREDS.fetch(adapter, CREDS[:sqlite]).dup end |
.default ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/legion/data/settings.rb', line 30 def self.default { adapter: 'sqlite', connected: false, # Connection pool max_connections: 25, pool_timeout: 5, preconnect: false, single_threaded: false, test: true, name: nil, # Logging log: false, query_log: false, log_connection_info: false, log_warn_duration: 1, sql_log_level: 'debug', # Connection health (network adapters only, ignored for sqlite) # Validation is disabled by default: the connection_validator extension issues a # SELECT NULL on every checkout/checkin and before real queries, which kills # throughput. Connection errors are already rescued and reconnected at query time. # When enabled, connection_validation_timeout: -1 validates on every checkout # (catches stale connections from VPN/sleep/network changes immediately). connection_validation: false, connection_validation_timeout: -1, connection_expiration: true, connection_expiration_timeout: 14_400, # Postgres session timeouts (milliseconds, applied via SET on each new connection). # statement_timeout bounds any single query; lock_timeout bounds lock acquisition. # These prevent a wedged SELECT or lock wait from hanging the process indefinitely. statement_timeout: 5000, lock_timeout: 2000, # TCP keepalives for Postgres (libpq connection params). # Detect half-open sockets where the peer vanished without FIN/RST. # keepalives_idle: seconds before first keepalive probe after idle # keepalives_interval: seconds between probes # keepalives_count: failed probes before declaring connection dead # tcp_user_timeout: total ms for unacked data before kernel drops connection (Linux) keepalives: 1, keepalives_idle: 10, keepalives_interval: 5, keepalives_count: 3, tcp_user_timeout: 15_000, # Shutdown: max seconds to wait for checked-out connections to return before # force-disconnecting them. shutdown_timeout: 5, # Adapter-specific (nil = use adapter built-in default) connect_timeout: nil, read_timeout: nil, write_timeout: nil, encoding: nil, sql_mode: nil, sslmode: nil, sslrootcert: nil, search_path: nil, timeout: nil, readonly: nil, disable_dqs: nil, # Grouped settings creds: creds, cache: cache, migrations: migrations, models: models, local: local, dev_mode: false, dev_fallback: true, connect_on_start: true, read_replica_url: nil, replicas: [], archival: archival } end |
.local ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/legion/data/settings.rb', line 111 def self.local { enabled: true, database: 'legionio_local.db', query_log: false, migrations: { auto_migrate: true } } end |
.migrations ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/legion/data/settings.rb', line 127 def self.migrations { continue_on_fail: false, auto_migrate: true, ran: false, version: nil } end |
.models ⇒ Object
120 121 122 123 124 125 |
# File 'lib/legion/data/settings.rb', line 120 def self.models { continue_on_load_fail: false, autoload: true } end |