Class: Bones::RPC::Celluloid::Connection::Writer
- Inherits:
-
Object
- Object
- Bones::RPC::Celluloid::Connection::Writer
- Includes:
- Celluloid::IO
- Defined in:
- lib/bones/rpc/celluloid/connection/writer.rb
Overview
Instance Method Summary collapse
-
#initialize(connection, socket, adapter) ⇒ Writer
constructor
A new instance of Writer.
- #reader_died(actor, reason) ⇒ Object
- #shutdown ⇒ Object
- #write(operations) ⇒ Object
Constructor Details
#initialize(connection, socket, adapter) ⇒ Writer
Returns a new instance of Writer.
13 14 15 16 17 18 19 20 |
# File 'lib/bones/rpc/celluloid/connection/writer.rb', line 13 def initialize(connection, socket, adapter) @connection = connection @socket = socket @adapter = adapter @resolved = @connection.node.address.resolved @buffer = "" @reader = Reader.new_link(@connection, @socket, @adapter) end |
Instance Method Details
#reader_died(actor, reason) ⇒ Object
43 44 45 46 47 |
# File 'lib/bones/rpc/celluloid/connection/writer.rb', line 43 def reader_died(actor, reason) Loggable.warn(" BONES-RPC:", "#{@resolved} Writer terminating: #{reason}", "n/a") @reader = nil terminate end |
#shutdown ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/bones/rpc/celluloid/connection/writer.rb', line 35 def shutdown if @reader && @reader.alive? @reader.unlink @reader.async.terminate end @connection.cleanup_socket(@socket) end |
#write(operations) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bones/rpc/celluloid/connection/writer.rb', line 22 def write(operations) operations.each do |, future| .serialize(@buffer, @adapter) .attach(@connection.node, future) if future end @socket.write(@buffer) @buffer = "" return true rescue EOFError, Errors::ConnectionFailure => e Loggable.warn(" BONES-RPC:", "#{@resolved} Writer terminating: #{e.}", "n/a") terminate end |