class Pantry::Config

Global configuration values for running all of Pantry.

Attributes

client_application[RW]

Application this Client serves

client_environment[RW]

Environment of the Application this Client runs

client_heartbeat_interval[RW]

How often, in seconds, the client pings the Server

client_identity[RW]

Unique identification of this Client

client_roles[RW]

Roles this Client serves

file_service_port[RW]

Port through which files are sent and received

log_level[RW]

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”

log_to[RW]

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”

pub_sub_port[RW]

Port used for Pub/Sub communication

receive_port[RW]

Port clients use to send information to the Server

response_timeout[RW]

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.

root_dir[RW]

Location on the file system Pantry will store any persistent data Default: /var/lib/pantry

security[RW]

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

server_host[RW]

Host name of the Pantry Server

syslog_program_name[RW]

If logging to Syslog, set the program-name Pantry will use when sending logs to syslog. Defaults to “pantry”

Public Class Methods

new() click to toggle source
# 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

load_file(config_file) click to toggle source

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
refresh() click to toggle source
# File lib/pantry/config.rb, line 121
def refresh
  apply_configuration
end

Protected Instance Methods

apply_configuration() click to toggle source
# 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
load_client_configs(configs) click to toggle source
# 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
load_global_configs(configs) click to toggle source
# 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
load_networking_configs(configs) click to toggle source
# 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