Class: KStor::Config
- Inherits:
-
Object
- Object
- KStor::Config
- Defined in:
- lib/kstor/config.rb
Overview
Configuration items stored as YAML.
Constant Summary collapse
- DEFAULTS =
Default values for configuration items.
They are used when loading configuration from a file, and for defining accessor methods.
{ 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze
Instance Attribute Summary collapse
-
#database ⇒ String
readonly
Path to SQLite database file.
-
#nworkers ⇒ Integer
readonly
Number of worker threads.
-
#session_idle_timeout ⇒ Integer
readonly
Seconds of inactivity before a session is closed.
-
#session_life_timeout ⇒ Integer
readonly
Seconds before a session is closed.
-
#socket ⇒ String
readonly
Path to KStor server listening socket.
Class Method Summary collapse
-
.load(path) ⇒ KStor::Config
Load configuration from a file.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Config
constructor
Create configuration from hash data.
Constructor Details
Instance Attribute Details
#database ⇒ String (readonly)
Returns path to SQLite database file.
27 28 29 30 31 32 33 34 |
# File 'lib/kstor/config.rb', line 27 DEFAULTS = { 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze |
#nworkers ⇒ Integer (readonly)
Returns number of worker threads.
27 28 29 30 31 32 33 34 |
# File 'lib/kstor/config.rb', line 27 DEFAULTS = { 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze |
#session_idle_timeout ⇒ Integer (readonly)
Returns seconds of inactivity before a session is closed.
27 28 29 30 31 32 33 34 |
# File 'lib/kstor/config.rb', line 27 DEFAULTS = { 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze |
#session_life_timeout ⇒ Integer (readonly)
Returns seconds before a session is closed.
27 28 29 30 31 32 33 34 |
# File 'lib/kstor/config.rb', line 27 DEFAULTS = { 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze |
#socket ⇒ String (readonly)
Returns path to KStor server listening socket.
27 28 29 30 31 32 33 34 |
# File 'lib/kstor/config.rb', line 27 DEFAULTS = { 'database' => '/var/lib/kstor/kstor.sqlite', 'socket' => '/run/kstor-server.socket', 'nworkers' => 5, 'session_idle_timeout' => 15 * 60, 'session_life_timeout' => 4 * 60 * 60, 'log_level' => 'warn' }.freeze |
Class Method Details
.load(path) ⇒ KStor::Config
Load configuration from a file.
For each missing configuration item in file, use the default from DEFAULTS.
44 45 46 47 48 49 50 51 |
# File 'lib/kstor/config.rb', line 44 def load(path) hash = if path && File.file?(path) YAML.load_file(path) else {} end new(hash) end |