Class: MyStuff::Fb303::Server

Inherits:
Object
  • Object
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
# 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)

  start_fb303_server
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object


53
54
55
56
57
58
59
# File 'lib/my_stuff/fb303/server.rb', line 53

def method_missing *args
  if self.handler != self
    self.handler.send *args
  else
    super *args
  end
end

Instance Method Details

#aliveSinceObject


33
# File 'lib/my_stuff/fb303/server.rb', line 33

def aliveSince; @started_at; end

#getCounter(key) ⇒ Object


35
# File 'lib/my_stuff/fb303/server.rb', line 35

def getCounter key; @counters[key]; end

#getCountersObject


34
# File 'lib/my_stuff/fb303/server.rb', line 34

def getCounters; @counters; end

#getCpuProfile(duration) ⇒ Object


38
# File 'lib/my_stuff/fb303/server.rb', line 38

def getCpuProfile duration; ''; end

#getNameObject

fb303 implementation #####


29
# File 'lib/my_stuff/fb303/server.rb', line 29

def getName; @name; end

#getOption(key) ⇒ Object


36
# File 'lib/my_stuff/fb303/server.rb', line 36

def getOption key; ''; end

#getOptionsObject


37
# File 'lib/my_stuff/fb303/server.rb', line 37

def getOptions; {}; end

#getStatusObject


31
# File 'lib/my_stuff/fb303/server.rb', line 31

def getStatus; @status; end

#getStatusDetailsObject


32
# File 'lib/my_stuff/fb303/server.rb', line 32

def getStatusDetails; @status_details; end

#getVersionObject


30
# File 'lib/my_stuff/fb303/server.rb', line 30

def getVersion; @version; end

#handlerObject


61
62
63
# File 'lib/my_stuff/fb303/server.rb', line 61

def handler
  self
end

#increment_counter(name) ⇒ Object


49
50
51
# File 'lib/my_stuff/fb303/server.rb', line 49

def increment_counter name
  @counters[name] += 1
end

#reinitializeObject

Raises:

  • (NotImplementedError)

40
# File 'lib/my_stuff/fb303/server.rb', line 40

def reinitialize; raise NotImplementedError.new; end

#run!Object


22
23
24
25
# File 'lib/my_stuff/fb303/server.rb', line 22

def run!
  @status  = Fb_status::ALIVE
  @server_thread.join
end

#setOption(key, value) ⇒ Object


39
# File 'lib/my_stuff/fb303/server.rb', line 39

def setOption key, value; end

#shutdownObject


42
43
44
45
46
47
# File 'lib/my_stuff/fb303/server.rb', line 42

def shutdown
  @status = Fb_status::STOPPING
  @status_details = 'Shutdown requested via fb303'
  @fb303_thread.kill
  @status = Fb_status::STOPPED
end