Class: MyStuff::Fb303::Server
- Inherits:
-
Object
- Object
- MyStuff::Fb303::Server
show all
- Defined in:
- lib/my_stuff/fb303/server.rb
Instance Method Summary
collapse
Constructor Details
#initialize(interface, name, version = '') ⇒ Server
Returns a new instance of Server.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/my_stuff/fb303/server.rb', line 9
def initialize interface, name, version = ''
@name = name
@version = version
@interface = interface
@status = Fb_status::STARTING
@status_details = ''
@started_at = Time.new.to_i
@counters = Hash.new(0)
logger.info 'Starting fb303 service...'
start_fb303_server
logger.info 'fb303 service running.'
logger.info 'Loading handler...'
handler
logger.info 'Handler loaded.'
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/my_stuff/fb303/server.rb', line 59
def method_missing *args
if self.handler != self
self.handler.send *args
else
super *args
end
end
|
Instance Method Details
#aliveSince ⇒ Object
39
|
# File 'lib/my_stuff/fb303/server.rb', line 39
def aliveSince; @started_at; end
|
#getCounter(key) ⇒ Object
41
|
# File 'lib/my_stuff/fb303/server.rb', line 41
def getCounter key; @counters[key]; end
|
#getCounters ⇒ Object
40
|
# File 'lib/my_stuff/fb303/server.rb', line 40
def getCounters; @counters; end
|
#getCpuProfile(duration) ⇒ Object
44
|
# File 'lib/my_stuff/fb303/server.rb', line 44
def getCpuProfile duration; ''; end
|
#getName ⇒ Object
fb303 implementation #####
35
|
# File 'lib/my_stuff/fb303/server.rb', line 35
def getName; @name; end
|
#getOption(key) ⇒ Object
42
|
# File 'lib/my_stuff/fb303/server.rb', line 42
def getOption key; ''; end
|
#getOptions ⇒ Object
43
|
# File 'lib/my_stuff/fb303/server.rb', line 43
def getOptions; {}; end
|
#getStatus ⇒ Object
37
|
# File 'lib/my_stuff/fb303/server.rb', line 37
def getStatus; @status; end
|
#getStatusDetails ⇒ Object
38
|
# File 'lib/my_stuff/fb303/server.rb', line 38
def getStatusDetails; @status_details; end
|
#getVersion ⇒ Object
36
|
# File 'lib/my_stuff/fb303/server.rb', line 36
def getVersion; @version; end
|
#handler ⇒ Object
67
68
69
|
# File 'lib/my_stuff/fb303/server.rb', line 67
def handler
self
end
|
#increment_counter(name) ⇒ Object
55
56
57
|
# File 'lib/my_stuff/fb303/server.rb', line 55
def increment_counter name
@counters[name] += 1
end
|
#logger ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/my_stuff/fb303/server.rb', line 71
def logger
if MyStuff.const_defined? :Logger
@logger ||= MyStuff::Logger.new
else
require 'logger'
@logger ||= Logger.new(STDOUT)
end
end
|
#reinitialize ⇒ Object
46
|
# File 'lib/my_stuff/fb303/server.rb', line 46
def reinitialize; raise NotImplementedError.new; end
|
#run! ⇒ Object
27
28
29
30
31
|
# File 'lib/my_stuff/fb303/server.rb', line 27
def run!
@status = Fb_status::ALIVE
logger.info 'Alive, waiting on server thread.'
@server_thread.join
end
|
#setOption(key, value) ⇒ Object
45
|
# File 'lib/my_stuff/fb303/server.rb', line 45
def setOption key, value; end
|
#shutdown ⇒ Object
48
49
50
51
52
53
|
# File 'lib/my_stuff/fb303/server.rb', line 48
def shutdown
@status = Fb_status::STOPPING
@status_details = 'Shutdown requested via fb303'
@fb303_thread.kill
@status = Fb_status::STOPPED
end
|