Sha256: 4fc4ad9d93c55db36fb9ed5ba3cc1a050818ad4d78a6726b8060e44a4f346cf2

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

module SneakersPacker
  class RpcRequest
    attr_reader :name, :call_id, :condition
    attr_reader :response_data, :from, :status

    def initialize(name, data)
      @name = name.to_s
      @data = data
      @call_id = SecureRandom.uuid

      @response = nil
      @processed = false
      @condition = ConditionVariable.new
    end

    def message
      SneakersPacker.message_packer.pack_request(@data)
    end

    def processed?
      @processed
    end

    def set_processed!
      @processed = true
    end

    def response=(value)
      @response_data, @from, @status = nil, nil, nil
      @response = value
      if value
        @response_data, @from, @status = SneakersPacker.message_packer.unpack_response(value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sneakers_packer-0.2.0 lib/sneakers_packer/rpc_request.rb
sneakers_packer-0.1.5 lib/sneakers_packer/rpc_request.rb