Methods
Included Modules
Attributes
[RW] worker_options
[RW] worker_started
Public Class methods
new()
    # File framework/worker.rb, line 24
24:     def initialize
25:       super
26:       @read_ios << msg_reader
27:       @read_ios << fd_reader
28:       @tokenizer = BinParser.new
29:     end
start_worker(messengers = {})

method initializes the eventloop for the worker

    # File framework/worker.rb, line 13
13:     def self.start_worker(messengers = {})
14:       # @fd_reader = args.shift if args.length > 2
15:       @msg_writer = messengers[:write_end]
16:       @msg_reader = messengers[:read_end]
17:       @fd_reader = messengers[:read_fd]
18:       t_instance = new
19:       t_instance.worker_options = messengers[:options]
20:       t_instance.worker_init if t_instance.respond_to?(:worker_init)
21:       t_instance.start_reactor
22:     end
Public Instance methods
handle_internal_messages(t_sock)

method handles internal requests from internal sockets

    # File framework/worker.rb, line 46
46:     def handle_internal_messages(t_sock)
47:       t_data = read_data(t_sock)
48:       receive_internal_data(t_data)
49:     end
invoke_callback()

message returns data to parent process, using UNIX Sockets

    # File framework/worker.rb, line 88
88:     def invoke_callback
89:       raise "Not implemented for worker"
90:     end
invoke_internal_function()

method checks if client has asked to execute a internal function

    # File framework/worker.rb, line 83
83:     def invoke_internal_function
84:       raise "Not implemented for worker"
85:     end
log(log_data)
    # File framework/worker.rb, line 73
73:     def log log_data
74:       send_data(:requested_worker => :log_worker,:data => log_data,:type => :request)
75:     end
provide_workers(handler_instance,connection)

FIXME: this method is being duplicated between packet and worker classes, may be its a good idea to merge them.

    # File framework/worker.rb, line 60
60:     def provide_workers(handler_instance,connection)
61:       class << handler_instance
62:         extend Forwardable
63:         attr_accessor :worker, :connection, :reactor, :initialized, :signature
64:         include NbioHelper
65:         include Connection
66:         def_delegators :@reactor, :start_server, :connect, :add_periodic_timer, :add_timer, :cancel_timer,:reconnect
67:       end
68:       handler_instance.connection = connection
69:       handler_instance.worker = self
70:       handler_instance.reactor = self
71:     end
receive_data(p_data)

method receives data from external TCP Sockets

    # File framework/worker.rb, line 78
78:     def receive_data p_data
79:       raise "Not implemented for worker"
80:     end
receive_internal_data(data)
    # File framework/worker.rb, line 51
51:     def receive_internal_data data
52:       @tokenizer.extract(data) do |b_data|
53:         data_obj = Marshal.load(b_data)
54:         receive_data(data_obj)
55:       end
56:     end
send_data(p_data)
    # File framework/worker.rb, line 31
31:     def send_data p_data
32:       dump_object(p_data,msg_writer)
33:     end
send_request(options = {})
    # File framework/worker.rb, line 35
35:     def send_request(options = {})
36:       t_data = options[:data]
37:       if t_callback = options[:callback]
38:         callback_hash[t_callback.signature] = t_callback
39:         send_data(:data => t_data,:function => options[:function],:callback_signature => t_callback.signature)
40:       else
41:         send_data(:data => t_data,:function => options[:function],:requested_worker => options[:worker],:requesting_worker => worker_name,:type => :request)
42:       end
43:     end