Class: Boogaloo::Config
- Inherits:
-
Object
- Object
- Boogaloo::Config
- Defined in:
- lib/boogaloo/config.rb
Overview
See examples/boogalooo.conf for an example configuration file.
Available Configuration Options
Section: Server
host
-
(required) The host name or IP address to bind the socket to.
port
-
(required) The port to bind the socket to.
worker_threads
-
(required) Boogaloo uses a pool of threads created at start-up that wait for requests to handle. 3 is a reasonable default.
debug
-
(optional) Enable/disable debugging. See DEBUGGING for for information.
Section: PersistentCaches
instance_name
-
(required) The name to use for accessing the cache on the client.
Example:
PersistentCaches:
MyPersistentCache:
instance_name: main_cache
Section: TemporaryCaches
instance_name
-
(required) The name to use for accessing the cache on the client.
check_frequency
-
(required) The frequency in seconds at which the cache will check for expired objects to delete.
Example:
TemporaryCaches:
MyTempCache:
instance_name: temp_cache
check_frequency: 10
Section: Services
instance_name
-
(required) The name to use for accessing the service on the client.
path
-
(required) The path to the directory containing your interface.rb file.
parameters
-
(optional) If your interface constructor accepts parameters you can specify them hear.
require_path
-
(optional) If your service needs to require files not in the standard $LOAD_PATH, you can specify directories to add to the $LOAD_PATH here either as a list or in singular form.
Example:
Services:
MyService:
instance_name: my_service
path: /home/me/BoogalooServices/MyService
parameters:
- Hello
- World
require_path:
- /some/dir
- /some/other/dir
Instance Method Summary collapse
-
#initialize(file) ⇒ Config
constructor
Initialize a new cofig instance.
-
#persistent_caches ⇒ Object
The entire PersistentCaches configuration section.
-
#server ⇒ Object
The entire Server configuration section.
-
#server_host ⇒ Object
The server host.
-
#server_port ⇒ Object
The server port.
-
#server_worker_threads ⇒ Object
The number of worker threads.
-
#services ⇒ Object
The entire Services configuration section.
-
#temporary_caches ⇒ Object
The entire TemporaryCaches configuration section.
Constructor Details
#initialize(file) ⇒ Config
Initialize a new cofig instance.
Parameters:
file
-
The configuration file to read.
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/boogaloo/config.rb', line 69 def initialize(file) @config = YAML.load File.read(file) error("Server configuration not found.") if not @config.key?('Server') error("host attribute missing for Server configuration.") if not @config['Server'].key?('host') error("port attribute missing for Server configuration.") if not @config['Server'].key?('port') error("worker_threads attribute missing for Server configuration.") if not @config['Server'].key?('worker_threads') @persistent_caches = {} @temporary_caches = {} @services = {} if @config['PersistentCaches'] @config['PersistentCaches'].each do |name, config| error "name attribute missing for persistent cache." if not name or not name.is_a?(String) error "configration missing for persistent cache '#{name}'." if not config.is_a?(Hash) error "instance_name attribute missing for persistent cache '#{name}'." if not config.key?('instance_name') conflict = nil @persistent_caches.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with persistent cache '#{conflict}'." if conflict @persistent_caches[name] = config end end if @config['TemporaryCaches'] @config['TemporaryCaches'].each do |name, config| error "name attribute missing for temporary cache." if not name or not name.is_a?(String) error "configration missing for temporary cache '#{name}'." if not config.is_a?(Hash) error "instance_name attribute missing for temporary cache '#{name}'." if not config.key?('instance_name') error "check_frequency attribute missing for temporary cache '#{name}'." if not config.key?('check_frequency') conflict = nil @temporary_caches.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with temporary cache '#{conflict}'." if conflict @persistent_caches.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with persistent cache '#{conflict}'." if conflict @temporary_caches[name] = config end end if @config['Services'] @config['Services'].each do |name, config| error "name attribute missing for service." if not name or not name.is_a?(String) error "configration missing for service cache '#{name}'." if not config.is_a?(Hash) error "path attribute missing for service '#{name}'." if not config.key?('path') error "instance_name attribute missing for service '#{name}'." if not config.key?('instance_name') conflict = nil @services.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with service '#{conflict}'." if conflict @temporary_caches.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with temporary cache '#{conflict}'." if conflict @persistent_caches.each { |key, value| conflict = key and break if value['instance_name'].eql?(config['instance_name'])} error "instance name '#{config['instance_name']}' for '#{name}' conflicts with persistent cache '#{conflict}'." if conflict @services[name] = config end end if @config['Server']['debug'] == true $debug = true notice("Debugging enabled") end end |
Instance Method Details
#persistent_caches ⇒ Object
The entire PersistentCaches configuration section.
184 185 186 187 188 |
# File 'lib/boogaloo/config.rb', line 184 def persistent_caches @persistent_caches end |
#server ⇒ Object
The entire Server configuration section.
156 157 158 159 160 |
# File 'lib/boogaloo/config.rb', line 156 def server @config['Server'] end |
#server_host ⇒ Object
The server host.
163 164 165 166 167 |
# File 'lib/boogaloo/config.rb', line 163 def server_host server['host'] end |
#server_port ⇒ Object
The server port.
170 171 172 173 174 |
# File 'lib/boogaloo/config.rb', line 170 def server_port server['port'] end |
#server_worker_threads ⇒ Object
The number of worker threads.
177 178 179 180 181 |
# File 'lib/boogaloo/config.rb', line 177 def server_worker_threads server['worker_threads'] end |
#services ⇒ Object
The entire Services configuration section.
198 199 200 201 202 |
# File 'lib/boogaloo/config.rb', line 198 def services @services end |
#temporary_caches ⇒ Object
The entire TemporaryCaches configuration section.
191 192 193 194 195 |
# File 'lib/boogaloo/config.rb', line 191 def temporary_caches @temporary_caches end |