class RailwayIpc::OutgoingMessage

Constants

DEFAULT_ENCODER

Attributes

exchange[R]
format[R]
proto[R]

Public Class Methods

new(proto, exchange, format=nil) click to toggle source
# File lib/railway_ipc/outgoing_message.rb, line 11
def initialize(proto, exchange, format=nil)
  proto.uuid = SecureRandom.uuid if proto.uuid.blank?
  proto.correlation_id = SecureRandom.uuid if proto.correlation_id.blank?
  @proto = proto
  @exchange = exchange
  @format = format
end

Public Instance Methods

encoded() click to toggle source
# File lib/railway_ipc/outgoing_message.rb, line 23
def encoded
  @encoded ||= encoder.call(self)
end
type() click to toggle source
# File lib/railway_ipc/outgoing_message.rb, line 19
def type
  proto.class.to_s
end

Private Instance Methods

encoder() click to toggle source
# File lib/railway_ipc/outgoing_message.rb, line 31
def encoder
  {
    'binary_protobuf' => RailwayIpc::MessageEncoders::ProtobufBinaryEncoder,
    'json_protobuf' => RailwayIpc::MessageEncoders::ProtobufJsonEncoder
  }.fetch(format, DEFAULT_ENCODER)
end