Class: Pantry::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/pantry/config.rb

Overview

Global configuration values for running all of Pantry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# 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

Instance Attribute Details

#client_applicationObject

Application this Client serves



73
74
75
# File 'lib/pantry/config.rb', line 73

def client_application
  @client_application
end

#client_environmentObject

Environment of the Application this Client runs



76
77
78
# File 'lib/pantry/config.rb', line 76

def client_environment
  @client_environment
end

#client_heartbeat_intervalObject

How often, in seconds, the client pings the Server



56
57
58
# File 'lib/pantry/config.rb', line 56

def client_heartbeat_interval
  @client_heartbeat_interval
end

#client_identityObject

Unique identification of this Client



70
71
72
# File 'lib/pantry/config.rb', line 70

def client_identity
  @client_identity
end

#client_rolesObject

Roles this Client serves



79
80
81
# File 'lib/pantry/config.rb', line 79

def client_roles
  @client_roles
end

#file_service_portObject

Port through which files are sent and received



53
54
55
# File 'lib/pantry/config.rb', line 53

def file_service_port
  @file_service_port
end

#log_levelObject

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”



28
29
30
# File 'lib/pantry/config.rb', line 28

def log_level
  @log_level
end

#log_toObject

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”



22
23
24
# File 'lib/pantry/config.rb', line 22

def log_to
  @log_to
end

#pub_sub_portObject

Port used for Pub/Sub communication



47
48
49
# File 'lib/pantry/config.rb', line 47

def pub_sub_port
  @pub_sub_port
end

#receive_portObject

Port clients use to send information to the Server



50
51
52
# File 'lib/pantry/config.rb', line 50

def receive_port
  @receive_port
end

#response_timeoutObject

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.



87
88
89
# File 'lib/pantry/config.rb', line 87

def response_timeout
  @response_timeout
end

#root_dirObject

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



37
38
39
# File 'lib/pantry/config.rb', line 37

def root_dir
  @root_dir
end

#securityObject

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



63
64
65
# File 'lib/pantry/config.rb', line 63

def security
  @security
end

#server_hostObject

Host name of the Pantry Server



44
45
46
# File 'lib/pantry/config.rb', line 44

def server_host
  @server_host
end

#syslog_program_nameObject

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



33
34
35
# File 'lib/pantry/config.rb', line 33

def syslog_program_name
  @syslog_program_name
end

Instance Method Details

#load_file(config_file) ⇒ Object

Given a YAML config file, read in config values



113
114
115
116
117
118
119
# 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

#refreshObject



121
122
123
# File 'lib/pantry/config.rb', line 121

def refresh
  apply_configuration
end