Class: Droonga::MessagePusher
- Inherits:
-
Object
- Object
- Droonga::MessagePusher
- Defined in:
- lib/droonga/message_pusher.rb
Instance Attribute Summary collapse
-
#raw_receiver ⇒ Object
readonly
Returns the value of attribute raw_receiver.
Instance Method Summary collapse
-
#initialize(loop) ⇒ MessagePusher
constructor
A new instance of MessagePusher.
- #push(message) ⇒ Object
- #shutdown ⇒ Object
- #start(base_path) ⇒ Object
Constructor Details
#initialize(loop) ⇒ MessagePusher
Returns a new instance of MessagePusher.
23 24 25 |
# File 'lib/droonga/message_pusher.rb', line 23 def initialize(loop) @loop = loop end |
Instance Attribute Details
#raw_receiver ⇒ Object (readonly)
Returns the value of attribute raw_receiver.
22 23 24 |
# File 'lib/droonga/message_pusher.rb', line 22 def raw_receiver @raw_receiver end |
Instance Method Details
#push(message) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/droonga/message_pusher.rb', line 42 def push() $log.trace("#{log_tag}: push: start") = .to_msgpack path = @raw_receiver.path sender = Coolio::UNIXSocket.connect(path) sender.write(.to_msgpack) sender.on_write_complete do close end @loop.attach(sender) $log.trace("#{log_tag}: push: done") end |
#shutdown ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/droonga/message_pusher.rb', line 34 def shutdown $log.trace("#{log_tag}: shutdown: start") socket_path = @raw_receiver.path @raw_receiver.close FileUtils.rm_f(socket_path) $log.trace("#{log_tag}: shutdown: done") end |
#start(base_path) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/droonga/message_pusher.rb', line 27 def start(base_path) socket_path = "#{base_path}.sock" FileUtils.rm_f(socket_path) @raw_receiver = UNIXServer.new(socket_path) FileUtils.chmod(0600, socket_path) end |