Class: Droonga::MessagePusher
- Inherits:
-
Object
- Object
- Droonga::MessagePusher
- Includes:
- Loggable
- 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
27 28 29 |
# File 'lib/droonga/message_pusher.rb', line 27 def initialize(loop) @loop = loop end |
Instance Attribute Details
#raw_receiver ⇒ Object (readonly)
Returns the value of attribute raw_receiver.
26 27 28 |
# File 'lib/droonga/message_pusher.rb', line 26 def raw_receiver @raw_receiver end |
Instance Method Details
#push(message) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/droonga/message_pusher.rb', line 46 def push() logger.trace("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) logger.trace("push: done") end |
#shutdown ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/droonga/message_pusher.rb', line 38 def shutdown logger.trace("shutdown: start") socket_path = @raw_receiver.path @raw_receiver.close FileUtils.rm_f(socket_path) logger.trace("shutdown: done") end |
#start(base_path) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/droonga/message_pusher.rb', line 31 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 |