class Bones::RPC::Celluloid::Connection::Writer

Public Class Methods

new(connection, socket, adapter) click to toggle source
# 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

Public Instance Methods

reader_died(actor, reason) click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# File lib/bones/rpc/celluloid/connection/writer.rb, line 22
def write(operations)
  operations.each do |message, future|
    message.serialize(@buffer, @adapter)
    message.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.message}", "n/a")
  terminate
end