Class: LS4::ProcessService

Inherits:
Service show all
Defined in:
lib/ls4/service/process.rb

Instance Method Summary collapse

Methods inherited from Service

init

Methods included from EventBus::SingletonMixin

#ebus_bind!, #ebus_connect, extended

Methods included from EventBus::BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from EventBus::DeclarerBase::Methods

#connect, #ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from EventBus::DeclarerBase

#call_slot, #signal_slot

Constructor Details

#initializeProcessService

Returns a new instance of ProcessService.



34
35
36
37
# File 'lib/ls4/service/process.rb', line 34

def initialize
	@net = MessagePack::RPC::Server.new
	submit_test
end

Instance Method Details

#get_session(addr) ⇒ Object



67
68
69
70
71
# File 'lib/ls4/service/process.rb', line 67

def get_session(addr)
	s = @net.get_session(addr)
	s.timeout = 10   # FIXME timeout
	s
end

#runObject



44
45
46
47
48
49
50
51
# File 'lib/ls4/service/process.rb', line 44

def run
	@timer = start_timer(1.0, true) do
		ProcessBus.on_timer
	end
	Signal.trap(:HUP) {
		ProcessBus.on_sighup
	}
end

#serve_rpc(dp) ⇒ Object



39
40
41
42
# File 'lib/ls4/service/process.rb', line 39

def serve_rpc(dp)
	@net.serve(dp)
	@net
end

#shutdownObject



59
60
61
# File 'lib/ls4/service/process.rb', line 59

def shutdown
	@net.loop.detach(@timer) if @timer
end

#start_timer(interval, periodic, &block) ⇒ Object



63
64
65
# File 'lib/ls4/service/process.rb', line 63

def start_timer(interval, periodic, &block)
	@net.start_timer(interval, periodic, &block)
end

#submit(task = nil, &block) ⇒ Object



53
54
55
56
57
# File 'lib/ls4/service/process.rb', line 53

def submit(task=nil, &block)
	task ||= block
	@net.submit(task)
	nil
end