Class: Sanford::ServerData
- Inherits:
-
Object
- Object
- Sanford::ServerData
- Defined in:
- lib/sanford/server_data.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#dtcp_logger ⇒ Object
readonly
Returns the value of attribute dtcp_logger.
-
#error_procs ⇒ Object
readonly
Returns the value of attribute error_procs.
-
#ip ⇒ Object
The server uses this to “compile” the common configuration data used by the server instances, error handlers and routes.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#num_workers ⇒ Object
readonly
Returns the value of attribute num_workers.
-
#pid_file ⇒ Object
readonly
Returns the value of attribute pid_file.
-
#port ⇒ Object
The server uses this to “compile” the common configuration data used by the server instances, error handlers and routes.
-
#process_label ⇒ Object
readonly
Returns the value of attribute process_label.
-
#receives_keep_alive ⇒ Object
readonly
Returns the value of attribute receives_keep_alive.
-
#router ⇒ Object
readonly
Returns the value of attribute router.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
-
#shutdown_timeout ⇒ Object
readonly
Returns the value of attribute shutdown_timeout.
-
#template_source ⇒ Object
readonly
Returns the value of attribute template_source.
-
#verbose_logging ⇒ Object
readonly
Returns the value of attribute verbose_logging.
-
#worker_class ⇒ Object
readonly
Returns the value of attribute worker_class.
-
#worker_params ⇒ Object
readonly
Returns the value of attribute worker_params.
Instance Method Summary collapse
-
#initialize(args = nil) ⇒ ServerData
constructor
A new instance of ServerData.
- #route_for(name) ⇒ Object
Constructor Details
#initialize(args = nil) ⇒ ServerData
Returns a new instance of ServerData.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/sanford/server_data.rb', line 17 def initialize(args = nil) args ||= {} @name = args[:name] @ip = !(v = ENV['SANFORD_IP'].to_s).empty? ? v : args[:ip] @port = !(v = ENV['SANFORD_PORT'].to_s).empty? ? v.to_i : args[:port] @pid_file = args[:pid_file] @shutdown_timeout = args[:shutdown_timeout] @worker_class = args[:worker_class] @worker_params = args[:worker_params] || {} @num_workers = args[:num_workers] @error_procs = args[:error_procs] || [] @template_source = args[:template_source] @logger = args[:logger] @router = args[:router] @receives_keep_alive = !!args[:receives_keep_alive] @verbose_logging = !!args[:verbose_logging] @debug = !ENV['SANFORD_DEBUG'].to_s.empty? @dtcp_logger = @logger if @debug @routes = build_routes(args[:routes] || []) @process_label = if (label = ENV['SANFORD_PROCESS_LABEL'].to_s).empty? "#{@name}-#{@ip}-#{@port}" else label end end |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
15 16 17 |
# File 'lib/sanford/server_data.rb', line 15 def debug @debug end |
#dtcp_logger ⇒ Object (readonly)
Returns the value of attribute dtcp_logger.
15 16 17 |
# File 'lib/sanford/server_data.rb', line 15 def dtcp_logger @dtcp_logger end |
#error_procs ⇒ Object (readonly)
Returns the value of attribute error_procs.
13 14 15 |
# File 'lib/sanford/server_data.rb', line 13 def error_procs @error_procs end |
#ip ⇒ Object
The server uses this to “compile” the common configuration data used by the server instances, error handlers and routes. The goal here is to provide these with a simplified interface with the minimal data needed and to decouple the configuration from each thing that needs its data.
10 11 12 |
# File 'lib/sanford/server_data.rb', line 10 def ip @ip end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/sanford/server_data.rb', line 13 def logger @logger end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/sanford/server_data.rb', line 11 def name @name end |
#num_workers ⇒ Object (readonly)
Returns the value of attribute num_workers.
12 13 14 |
# File 'lib/sanford/server_data.rb', line 12 def num_workers @num_workers end |
#pid_file ⇒ Object (readonly)
Returns the value of attribute pid_file.
11 12 13 |
# File 'lib/sanford/server_data.rb', line 11 def pid_file @pid_file end |
#port ⇒ Object
The server uses this to “compile” the common configuration data used by the server instances, error handlers and routes. The goal here is to provide these with a simplified interface with the minimal data needed and to decouple the configuration from each thing that needs its data.
10 11 12 |
# File 'lib/sanford/server_data.rb', line 10 def port @port end |
#process_label ⇒ Object (readonly)
Returns the value of attribute process_label.
15 16 17 |
# File 'lib/sanford/server_data.rb', line 15 def process_label @process_label end |
#receives_keep_alive ⇒ Object (readonly)
Returns the value of attribute receives_keep_alive.
14 15 16 |
# File 'lib/sanford/server_data.rb', line 14 def receives_keep_alive @receives_keep_alive end |
#router ⇒ Object (readonly)
Returns the value of attribute router.
13 14 15 |
# File 'lib/sanford/server_data.rb', line 13 def router @router end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
15 16 17 |
# File 'lib/sanford/server_data.rb', line 15 def routes @routes end |
#shutdown_timeout ⇒ Object (readonly)
Returns the value of attribute shutdown_timeout.
11 12 13 |
# File 'lib/sanford/server_data.rb', line 11 def shutdown_timeout @shutdown_timeout end |
#template_source ⇒ Object (readonly)
Returns the value of attribute template_source.
13 14 15 |
# File 'lib/sanford/server_data.rb', line 13 def template_source @template_source end |
#verbose_logging ⇒ Object (readonly)
Returns the value of attribute verbose_logging.
14 15 16 |
# File 'lib/sanford/server_data.rb', line 14 def verbose_logging @verbose_logging end |
#worker_class ⇒ Object (readonly)
Returns the value of attribute worker_class.
12 13 14 |
# File 'lib/sanford/server_data.rb', line 12 def worker_class @worker_class end |
#worker_params ⇒ Object (readonly)
Returns the value of attribute worker_params.
12 13 14 |
# File 'lib/sanford/server_data.rb', line 12 def worker_params @worker_params end |
Instance Method Details
#route_for(name) ⇒ Object
48 49 50 |
# File 'lib/sanford/server_data.rb', line 48 def route_for(name) @routes[name] || raise(NotFoundError, "no service named '#{name}'") end |