sanford 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +41 -56
  3. data/Rakefile +0 -1
  4. data/bench/client.rb +8 -3
  5. data/bench/{services.rb → config.sanford} +11 -6
  6. data/bench/{runner.rb → report.rb} +2 -2
  7. data/bench/report.txt +32 -32
  8. data/lib/sanford/cli.rb +42 -28
  9. data/lib/sanford/config_file.rb +79 -0
  10. data/lib/sanford/{worker.rb → connection_handler.rb} +28 -20
  11. data/lib/sanford/error_handler.rb +7 -7
  12. data/lib/sanford/pid_file.rb +42 -0
  13. data/lib/sanford/process.rb +136 -0
  14. data/lib/sanford/process_signal.rb +20 -0
  15. data/lib/sanford/route.rb +48 -0
  16. data/lib/sanford/router.rb +36 -0
  17. data/lib/sanford/runner.rb +30 -58
  18. data/lib/sanford/sanford_runner.rb +19 -9
  19. data/lib/sanford/server.rb +211 -42
  20. data/lib/sanford/server_data.rb +47 -0
  21. data/lib/sanford/service_handler.rb +8 -46
  22. data/lib/sanford/template_source.rb +19 -2
  23. data/lib/sanford/test_runner.rb +27 -28
  24. data/lib/sanford/version.rb +1 -1
  25. data/lib/sanford.rb +1 -23
  26. data/sanford.gemspec +4 -5
  27. data/test/helper.rb +3 -20
  28. data/test/support/app_server.rb +142 -0
  29. data/test/support/config.sanford +7 -0
  30. data/test/support/config_invalid_run.sanford +3 -0
  31. data/test/support/config_no_run.sanford +0 -0
  32. data/test/support/fake_server_connection.rb +58 -0
  33. data/test/support/pid_file_spy.rb +19 -0
  34. data/test/support/template.erb +1 -0
  35. data/test/system/server_tests.rb +378 -0
  36. data/test/system/service_handler_tests.rb +224 -0
  37. data/test/unit/cli_tests.rb +187 -0
  38. data/test/unit/config_file_tests.rb +59 -0
  39. data/test/unit/connection_handler_tests.rb +254 -0
  40. data/test/unit/error_handler_tests.rb +30 -35
  41. data/test/unit/pid_file_tests.rb +70 -0
  42. data/test/unit/process_signal_tests.rb +61 -0
  43. data/test/unit/process_tests.rb +428 -0
  44. data/test/unit/route_tests.rb +92 -0
  45. data/test/unit/router_tests.rb +65 -0
  46. data/test/unit/runner_tests.rb +61 -15
  47. data/test/unit/sanford_runner_tests.rb +162 -28
  48. data/test/unit/sanford_tests.rb +0 -8
  49. data/test/unit/server_data_tests.rb +87 -0
  50. data/test/unit/server_tests.rb +502 -21
  51. data/test/unit/service_handler_tests.rb +114 -219
  52. data/test/unit/template_engine_tests.rb +1 -1
  53. data/test/unit/template_source_tests.rb +56 -16
  54. data/test/unit/test_runner_tests.rb +206 -0
  55. metadata +67 -67
  56. data/bench/tasks.rb +0 -41
  57. data/lib/sanford/config.rb +0 -28
  58. data/lib/sanford/host.rb +0 -129
  59. data/lib/sanford/host_data.rb +0 -65
  60. data/lib/sanford/hosts.rb +0 -38
  61. data/lib/sanford/manager.rb +0 -275
  62. data/test/support/fake_connection.rb +0 -36
  63. data/test/support/helpers.rb +0 -17
  64. data/test/support/service_handlers.rb +0 -154
  65. data/test/support/services.rb +0 -123
  66. data/test/support/simple_client.rb +0 -62
  67. data/test/system/request_handling_tests.rb +0 -306
  68. data/test/unit/config_tests.rb +0 -56
  69. data/test/unit/host_data_tests.rb +0 -71
  70. data/test/unit/host_tests.rb +0 -141
  71. data/test/unit/hosts_tests.rb +0 -50
  72. data/test/unit/manager_tests.rb +0 -195
  73. data/test/unit/worker_tests.rb +0 -24
@@ -0,0 +1,206 @@
1
+ require 'assert'
2
+ require 'sanford/test_runner'
3
+
4
+ class Sanford::TestRunner
5
+
6
+ class UnitTests < Assert::Context
7
+ desc "Sanford::TestRunner"
8
+ setup do
9
+ @handler_class = TestServiceHandler
10
+ @request = Sanford::Protocol::Request.new(Factory.string, {})
11
+ @params = { :something => Factory.string }
12
+ @logger = Factory.string
13
+ @template_source = Factory.string
14
+ @handler_flag = Factory.boolean
15
+
16
+ @runner_class = Sanford::TestRunner
17
+ end
18
+ subject{ @runner_class }
19
+
20
+ should "be a runner" do
21
+ assert_true subject < Sanford::Runner
22
+ end
23
+
24
+ end
25
+
26
+ class InitTests < UnitTests
27
+ desc "when init"
28
+ setup do
29
+ @args = {
30
+ :request => @request,
31
+ :params => @params,
32
+ :logger => @logger,
33
+ :template_source => @template_source,
34
+ :flag => @handler_flag
35
+ }
36
+ @runner = @runner_class.new(@handler_class, @args)
37
+ end
38
+ subject{ @runner }
39
+
40
+ should have_readers :response
41
+ should have_imeths :run
42
+
43
+ should "know its attributes" do
44
+ assert_equal @request, subject.request
45
+ assert_equal @params, subject.params
46
+ assert_equal @logger, subject.logger
47
+ assert_equal @template_source, subject.template_source
48
+ end
49
+
50
+ should "write extra args to its service handler" do
51
+ assert_equal @handler_flag, subject.handler.flag
52
+ end
53
+
54
+ should "not alter the args passed to it" do
55
+ assert_equal @request, @args[:request]
56
+ assert_equal @params, @args[:params]
57
+ assert_equal @logger, @args[:logger]
58
+ assert_equal @template_source, @args[:template_source]
59
+ assert_equal @handler_flag, @args[:flag]
60
+ end
61
+
62
+ should "default its request, logger, params and template source" do
63
+ test_runner = @runner_class.new(@handler_class)
64
+ assert_nil test_runner.request
65
+ assert_equal({}, test_runner.params)
66
+ assert_instance_of Sanford::NullLogger, test_runner.logger
67
+ assert_instance_of Sanford::NullTemplateSource, test_runner.template_source
68
+ end
69
+
70
+ should "not have called its service handlers before callbacks" do
71
+ assert_nil subject.handler.before_called
72
+ end
73
+
74
+ should "have called init on its service handler" do
75
+ assert_true subject.handler.init_called
76
+ end
77
+
78
+ should "not have a response by default" do
79
+ assert_nil subject.response
80
+ end
81
+
82
+ should "raise an invalid error when not passed a service handler" do
83
+ assert_raises(Sanford::InvalidServiceHandlerError) do
84
+ @runner_class.new(Class.new)
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ class RunTests < InitTests
91
+ desc "and run"
92
+ setup do
93
+ @response = @runner.run
94
+ end
95
+ subject{ @response }
96
+
97
+ should "know its response" do
98
+ assert_equal subject, @runner.response
99
+ assert_instance_of Sanford::Protocol::Response, subject
100
+ end
101
+
102
+ should "have called run on its service handler" do
103
+ assert_true @runner.handler.run_called
104
+ end
105
+
106
+ should "not have called its service handlers after callbacks" do
107
+ assert_nil @runner.handler.after_called
108
+ end
109
+
110
+ end
111
+
112
+ class RunWithInvalidResponseTests < InitTests
113
+ desc "and run with an invalid response"
114
+ setup do
115
+ @runner.handler.response = Class.new
116
+ end
117
+
118
+ should "raise a serialization error" do
119
+ assert_raises(BSON::InvalidDocument){ subject.run }
120
+ end
121
+
122
+ end
123
+
124
+ class InitThatHaltsTests < UnitTests
125
+ desc "when init with a handler that halts in its init"
126
+ setup do
127
+ @runner = @runner_class.new(HaltServiceHandler)
128
+ end
129
+ subject{ @runner }
130
+
131
+ should "know the response from the init halting" do
132
+ assert_instance_of Sanford::Protocol::Response, subject.response
133
+ assert_equal subject.handler.response_code, subject.response.code
134
+ end
135
+
136
+ end
137
+
138
+ class RunWithInitThatHaltsTests < InitThatHaltsTests
139
+ desc "is run"
140
+ setup do
141
+ @response = @runner.run
142
+ end
143
+ subject{ @response }
144
+
145
+ should "not call run on the service handler" do
146
+ assert_false @runner.handler.run_called
147
+ end
148
+
149
+ should "return the response from the init halting" do
150
+ assert_instance_of Sanford::Protocol::Response, subject
151
+ assert_equal @runner.handler.response_code, subject.code
152
+ end
153
+
154
+ end
155
+
156
+ class RunWithInvalidResponseFromInitHaltTests < UnitTests
157
+ desc "when init with a handler that halts in its init an invalid response"
158
+
159
+ should "raise a serialization error" do
160
+ assert_raises(BSON::InvalidDocument) do
161
+ @runner_class.new(HaltServiceHandler, :response_data => Class.new)
162
+ end
163
+ end
164
+
165
+ end
166
+
167
+ class TestServiceHandler
168
+ include Sanford::ServiceHandler
169
+
170
+ attr_reader :before_called, :after_called
171
+ attr_reader :init_called, :run_called
172
+ attr_accessor :flag, :response
173
+
174
+ before{ @before_called = true }
175
+ after{ @after_called = true }
176
+
177
+ def init!
178
+ @init_called = true
179
+ @run_called = false
180
+ end
181
+
182
+ def run!
183
+ @run_called = true
184
+ @response || Factory.boolean
185
+ end
186
+ end
187
+
188
+ class HaltServiceHandler
189
+ include Sanford::ServiceHandler
190
+
191
+ attr_reader :run_called
192
+ attr_accessor :response_code, :response_data
193
+
194
+ def init!
195
+ @run_called = false
196
+ @response_code ||= Factory.integer
197
+ @response_data ||= Factory.string
198
+ halt(@response_code, :data => @response_data)
199
+ end
200
+
201
+ def run!
202
+ @run_called = true
203
+ end
204
+ end
205
+
206
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanford
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 51
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 10
9
- - 1
10
- version: 0.10.1
8
+ - 11
9
+ - 0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-06-11 00:00:00 Z
19
+ date: 2014-06-30 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 3
27
+ hash: 1
28
28
  segments:
29
29
  - 0
30
- - 4
31
- version: "0.4"
30
+ - 5
31
+ version: "0.5"
32
+ version_requirements: *id001
32
33
  type: :runtime
33
34
  name: dat-tcp
34
- version_requirements: *id001
35
35
  prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
@@ -44,9 +44,9 @@ dependencies:
44
44
  - 1
45
45
  - 1
46
46
  version: "1.1"
47
+ version_requirements: *id002
47
48
  type: :runtime
48
49
  name: ns-options
49
- version_requirements: *id002
50
50
  prerelease: false
51
51
  - !ruby/object:Gem::Dependency
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
@@ -54,14 +54,14 @@ dependencies:
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- hash: 27
57
+ hash: 25
58
58
  segments:
59
59
  - 0
60
- - 8
61
- version: "0.8"
60
+ - 9
61
+ version: "0.9"
62
+ version_requirements: *id003
62
63
  type: :runtime
63
64
  name: sanford-protocol
64
- version_requirements: *id003
65
65
  prerelease: false
66
66
  - !ruby/object:Gem::Dependency
67
67
  requirement: &id004 !ruby/object:Gem::Requirement
@@ -69,29 +69,14 @@ dependencies:
69
69
  requirements:
70
70
  - - ~>
71
71
  - !ruby/object:Gem::Version
72
- hash: 23
72
+ hash: 21
73
73
  segments:
74
74
  - 2
75
- - 10
76
- version: "2.10"
77
- type: :development
78
- name: assert
75
+ - 11
76
+ version: "2.11"
79
77
  version_requirements: *id004
80
- prerelease: false
81
- - !ruby/object:Gem::Dependency
82
- requirement: &id005 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ~>
86
- - !ruby/object:Gem::Version
87
- hash: 13
88
- segments:
89
- - 1
90
- - 1
91
- version: "1.1"
92
78
  type: :development
93
- name: assert-mocha
94
- version_requirements: *id005
79
+ name: assert
95
80
  prerelease: false
96
81
  description: Sanford TCP protocol server for hosting services
97
82
  email:
@@ -110,57 +95,65 @@ files:
110
95
  - README.md
111
96
  - Rakefile
112
97
  - bench/client.rb
98
+ - bench/config.sanford
99
+ - bench/report.rb
113
100
  - bench/report.txt
114
- - bench/runner.rb
115
- - bench/services.rb
116
- - bench/tasks.rb
117
101
  - bin/sanford
118
102
  - lib/sanford.rb
119
103
  - lib/sanford/cli.rb
120
- - lib/sanford/config.rb
104
+ - lib/sanford/config_file.rb
105
+ - lib/sanford/connection_handler.rb
121
106
  - lib/sanford/error_handler.rb
122
- - lib/sanford/host.rb
123
- - lib/sanford/host_data.rb
124
- - lib/sanford/hosts.rb
125
107
  - lib/sanford/logger.rb
126
- - lib/sanford/manager.rb
108
+ - lib/sanford/pid_file.rb
109
+ - lib/sanford/process.rb
110
+ - lib/sanford/process_signal.rb
111
+ - lib/sanford/route.rb
112
+ - lib/sanford/router.rb
127
113
  - lib/sanford/runner.rb
128
114
  - lib/sanford/sanford_runner.rb
129
115
  - lib/sanford/server.rb
116
+ - lib/sanford/server_data.rb
130
117
  - lib/sanford/service_handler.rb
131
118
  - lib/sanford/template_engine.rb
132
119
  - lib/sanford/template_source.rb
133
120
  - lib/sanford/test_helpers.rb
134
121
  - lib/sanford/test_runner.rb
135
122
  - lib/sanford/version.rb
136
- - lib/sanford/worker.rb
137
123
  - log/.gitkeep
138
124
  - sanford.gemspec
139
125
  - test/helper.rb
126
+ - test/support/app_server.rb
127
+ - test/support/config.sanford
128
+ - test/support/config_invalid_run.sanford
129
+ - test/support/config_no_run.sanford
140
130
  - test/support/factory.rb
141
- - test/support/fake_connection.rb
142
- - test/support/helpers.rb
143
- - test/support/service_handlers.rb
144
- - test/support/services.rb
145
- - test/support/simple_client.rb
131
+ - test/support/fake_server_connection.rb
132
+ - test/support/pid_file_spy.rb
133
+ - test/support/template.erb
146
134
  - test/support/template.json
147
135
  - test/support/test_disallowed_template.rb
148
136
  - test/support/test_template.test
149
- - test/system/request_handling_tests.rb
150
- - test/unit/config_tests.rb
137
+ - test/system/server_tests.rb
138
+ - test/system/service_handler_tests.rb
139
+ - test/unit/cli_tests.rb
140
+ - test/unit/config_file_tests.rb
141
+ - test/unit/connection_handler_tests.rb
151
142
  - test/unit/error_handler_tests.rb
152
- - test/unit/host_data_tests.rb
153
- - test/unit/host_tests.rb
154
- - test/unit/hosts_tests.rb
155
- - test/unit/manager_tests.rb
143
+ - test/unit/pid_file_tests.rb
144
+ - test/unit/process_signal_tests.rb
145
+ - test/unit/process_tests.rb
146
+ - test/unit/route_tests.rb
147
+ - test/unit/router_tests.rb
156
148
  - test/unit/runner_tests.rb
157
149
  - test/unit/sanford_runner_tests.rb
158
150
  - test/unit/sanford_tests.rb
151
+ - test/unit/server_data_tests.rb
159
152
  - test/unit/server_tests.rb
160
153
  - test/unit/service_handler_tests.rb
161
154
  - test/unit/template_engine_tests.rb
162
155
  - test/unit/template_source_tests.rb
163
- - test/unit/worker_tests.rb
156
+ - test/unit/test_runner_tests.rb
164
157
  - tmp/.gitkeep
165
158
  homepage: https://github.com/redding/sanford
166
159
  licenses:
@@ -191,33 +184,40 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
184
  requirements: []
192
185
 
193
186
  rubyforge_project:
194
- rubygems_version: 1.8.25
187
+ rubygems_version: 1.8.29
195
188
  signing_key:
196
189
  specification_version: 3
197
190
  summary: Sanford TCP protocol server for hosting services
198
191
  test_files:
199
192
  - test/helper.rb
193
+ - test/support/app_server.rb
194
+ - test/support/config.sanford
195
+ - test/support/config_invalid_run.sanford
196
+ - test/support/config_no_run.sanford
200
197
  - test/support/factory.rb
201
- - test/support/fake_connection.rb
202
- - test/support/helpers.rb
203
- - test/support/service_handlers.rb
204
- - test/support/services.rb
205
- - test/support/simple_client.rb
198
+ - test/support/fake_server_connection.rb
199
+ - test/support/pid_file_spy.rb
200
+ - test/support/template.erb
206
201
  - test/support/template.json
207
202
  - test/support/test_disallowed_template.rb
208
203
  - test/support/test_template.test
209
- - test/system/request_handling_tests.rb
210
- - test/unit/config_tests.rb
204
+ - test/system/server_tests.rb
205
+ - test/system/service_handler_tests.rb
206
+ - test/unit/cli_tests.rb
207
+ - test/unit/config_file_tests.rb
208
+ - test/unit/connection_handler_tests.rb
211
209
  - test/unit/error_handler_tests.rb
212
- - test/unit/host_data_tests.rb
213
- - test/unit/host_tests.rb
214
- - test/unit/hosts_tests.rb
215
- - test/unit/manager_tests.rb
210
+ - test/unit/pid_file_tests.rb
211
+ - test/unit/process_signal_tests.rb
212
+ - test/unit/process_tests.rb
213
+ - test/unit/route_tests.rb
214
+ - test/unit/router_tests.rb
216
215
  - test/unit/runner_tests.rb
217
216
  - test/unit/sanford_runner_tests.rb
218
217
  - test/unit/sanford_tests.rb
218
+ - test/unit/server_data_tests.rb
219
219
  - test/unit/server_tests.rb
220
220
  - test/unit/service_handler_tests.rb
221
221
  - test/unit/template_engine_tests.rb
222
222
  - test/unit/template_source_tests.rb
223
- - test/unit/worker_tests.rb
223
+ - test/unit/test_runner_tests.rb
data/bench/tasks.rb DELETED
@@ -1,41 +0,0 @@
1
- namespace :bench do
2
-
3
- task :load do
4
- require 'bench/runner'
5
- end
6
-
7
- namespace :server do
8
-
9
- task :load do
10
- ENV['SANFORD_SERVICES_FILE'] = 'bench/services'
11
- end
12
-
13
- desc "Run the bench server"
14
- task :run => :load do
15
- Kernel.exec("bundle exec sanford run")
16
- end
17
-
18
- desc "Start a daemonized bench server"
19
- task :start => :load do
20
- Kernel.system("bundle exec sanford start")
21
- end
22
-
23
- desc "Stop the bench server"
24
- task :stop => :load do
25
- Kernel.system("bundle exec sanford stop")
26
- end
27
-
28
- end
29
-
30
- desc "Run a Benchmark report against the Benchmark server"
31
- task :report => :load do
32
- Bench::Runner.new.build_report
33
- end
34
-
35
- desc "Run Benchmark requests against the 'simple' service"
36
- task :simple, [ :times ] => :load do |t, args|
37
- runner = Bench::Runner.new(:output => '/dev/null')
38
- runner.benchmark_service('v1', 'simple', {}, args[:times] || 1, true)
39
- end
40
-
41
- end
@@ -1,28 +0,0 @@
1
- require 'ns-options'
2
- require 'pathname'
3
- require 'sanford/logger'
4
- require 'sanford/runner'
5
- require 'sanford/template_source'
6
-
7
- module Sanford
8
-
9
- class Config
10
- include NsOptions::Proxy
11
-
12
- option :services_file, Pathname, :default => proc{ ENV['SANFORD_SERVICES_FILE'] }
13
- option :logger, :default => proc{ Sanford::NullLogger.new }
14
-
15
- attr_reader :template_source
16
-
17
- def initialize
18
- super
19
- @template_source = NullTemplateSource.new
20
- end
21
-
22
- def set_template_source(path, &block)
23
- @template_source = TemplateSource.new(path).tap{ |s| block.call(s) if block }
24
- end
25
-
26
- end
27
-
28
- end
data/lib/sanford/host.rb DELETED
@@ -1,129 +0,0 @@
1
- require 'ns-options'
2
- require 'pathname'
3
- require 'singleton'
4
-
5
- require 'sanford/logger'
6
-
7
- module Sanford
8
-
9
- module Host
10
-
11
- class Configuration
12
- include NsOptions::Proxy
13
-
14
- # A Host's configuration is a seperate ns-options proxy class because
15
- # `Host` is a module, so it itself cannot be a ns-options proxy (and
16
- # still function as a mixin). Also, since it is making the `Host`
17
- # a `Singleton`, mixing that with `NsOptions::Proxy` could have strange
18
- # effects (messing up someone's `initialize`). Thus, the `Configuration`
19
- # is a separate class and not on the `Host` directly.
20
-
21
- option :name, String
22
- option :ip, String, :default => '0.0.0.0'
23
- option :port, Integer
24
- option :pid_file, Pathname
25
- option :logger, :default => proc{ Sanford.config.logger }
26
- option :verbose_logging, :default => true
27
- option :receives_keep_alive, :default => false
28
- option :error_procs, Array, :default => []
29
- option :init_procs, Array, :default => []
30
-
31
- def initialize(host)
32
- self.name = host.class.to_s
33
- end
34
-
35
- end
36
-
37
- def self.included(host_class)
38
- host_class.class_eval do
39
- include Singleton
40
- extend Sanford::Host::ClassMethods
41
- end
42
- Sanford.register(host_class)
43
- end
44
-
45
- attr_reader :configuration, :services
46
-
47
- def initialize
48
- @configuration = Configuration.new(self)
49
- @service_handler_ns = nil
50
- @services = {}
51
- end
52
-
53
- def name(*args)
54
- self.configuration.name *args
55
- end
56
-
57
- def ip(*args)
58
- self.configuration.ip *args
59
- end
60
-
61
- def port(*args)
62
- self.configuration.port *args
63
- end
64
-
65
- def pid_file(*args)
66
- self.configuration.pid_file *args
67
- end
68
-
69
- def logger(*args)
70
- self.configuration.logger *args
71
- end
72
-
73
- def verbose_logging(*args)
74
- self.configuration.verbose_logging *args
75
- end
76
-
77
- def receives_keep_alive(*args)
78
- self.configuration.receives_keep_alive *args
79
- end
80
-
81
- def error(&block)
82
- self.configuration.error_procs << block
83
- end
84
-
85
- def init(&block)
86
- self.configuration.init_procs << block
87
- end
88
-
89
- def service_handler_ns(value = nil)
90
- @service_handler_ns = value if value
91
- @service_handler_ns
92
- end
93
-
94
- def service(service_name, handler_class_name)
95
- if @service_handler_ns && !(handler_class_name =~ /^::/)
96
- handler_class_name = "#{@service_handler_ns}::#{handler_class_name}"
97
- end
98
- @services[service_name.to_s] = handler_class_name
99
- end
100
-
101
- def inspect
102
- reference = '0x0%x' % (self.object_id << 1)
103
- "#<#{self.class}:#{reference} ip=#{self.configuration.ip.inspect} " \
104
- "port=#{self.configuration.port.inspect}>"
105
- end
106
-
107
- module ClassMethods
108
-
109
- # the class level of a `Host` should just proxy its methods down to its
110
- # instance (it's a `Singleton`)
111
-
112
- # `name` is defined by all objects, so we can't rely on `method_missing`
113
- def name(*args)
114
- self.instance.name(*args)
115
- end
116
-
117
- def method_missing(method, *args, &block)
118
- self.instance.send(method, *args, &block)
119
- end
120
-
121
- def respond_to?(method)
122
- super || self.instance.respond_to?(method)
123
- end
124
-
125
- end
126
-
127
- end
128
-
129
- end