class Pantry::Config
Global configuration values for running all of Pantry
.
Attributes
Application this Client
serves
Environment of the Application this Client
runs
How often, in seconds, the client pings the Server
Unique identification of this Client
Roles this Client
serves
Port through which files are sent and received
After what level are logs dropped and ignored? Can be any of: “fatal”, “error”, “warn”, “info”, “debug” Each level will include the logs of all levels above it. Defaults to “info”
Where does Pantry
log to? Can be “stdout”, “syslog”, or a file system path Defaults to STDOUT When using syslog, program name will be “pantry”
Port used for Pub/Sub communication
Port clients use to send information to the Server
Time in seconds the CLI
will wait for a response from the server By default this is nil, meaning unlimited timeout. Used mainly in tests.
Location on the file system Pantry
will store any persistent data Default: /var/lib/pantry
What type of security will Pantry
be employing? Available types are nil (no security) and “curve” (ZMQ4 Curve security)
Defaults to nil because curve security has not yet been fully vetted by the crypto-community
If logging to Syslog, set the program-name Pantry
will use when sending logs to syslog. Defaults to “pantry”
Public Class Methods
# File lib/pantry/config.rb, line 89 def initialize # Logging defaults @log_level = "info" @syslog_program_name = "pantry" # Default connectivity settings @server_host = "127.0.0.1" @pub_sub_port = 23001 @receive_port = 23002 @file_service_port = 23003 # Default client heartbeat to every 5 minutes @client_heartbeat_interval = 300 # Default Client identificiation values @client_identity = nil @client_application = nil @client_environment = nil @client_roles = [] end
Public Instance Methods
Given a YAML config file, read in config values
# File lib/pantry/config.rb, line 113 def load_file(config_file) configs = SafeYAML.load_file(config_file) load_global_configs(configs) load_networking_configs(configs["networking"]) load_client_configs(configs["client"]) refresh end
# File lib/pantry/config.rb, line 121 def refresh apply_configuration end
Protected Instance Methods
# File lib/pantry/config.rb, line 176 def apply_configuration # Reset our logger knowledge so the next call picks up the # new configs Pantry.logger = nil end
# File lib/pantry/config.rb, line 163 def load_client_configs(configs) return unless configs @client_identity = configs["identity"] @client_application = configs["application"] @client_environment = configs["environment"] @client_roles = configs["roles"] if configs["heartbeat_interval"] @client_heartbeat_interval = configs["heartbeat_interval"] end end
# File lib/pantry/config.rb, line 127 def load_global_configs(configs) @log_to = configs["log_to"] if configs["log_level"] @log_level = configs["log_level"] end if configs["syslog_program_name"] @syslog_program_name = configs["syslog_program_name"] end @root_dir = configs["root_dir"] end
# File lib/pantry/config.rb, line 141 def load_networking_configs(configs) return unless configs if configs["server_host"] @server_host = configs["server_host"] end if configs["pub_sub_port"] @pub_sub_port = configs["pub_sub_port"] end if configs["receive_port"] @receive_port = configs["receive_port"] end if configs["file_service_port"] @file_service_port = configs["file_service_port"] end @security = configs["security"] end