module EM::Voldemort::Protocol

Implementation of Voldemort’s pb0 (protocol buffers) protocol. Very incomplete – currently only supports the get command.

Public Instance Methods

get_request(store, key) click to toggle source
# File lib/em-voldemort/protocol.rb, line 5
def get_request(store, key)
  Protobuf::Request.new(
    :type => Protobuf::RequestType::GET,
    :should_route => false,
    :store => store.to_s,
    :get => Protobuf::GetRequest.new(:key => key.to_s)
  ).encode.to_s
end
get_response(bytes) click to toggle source
# File lib/em-voldemort/protocol.rb, line 14
def get_response(bytes)
  response = Protobuf::GetResponse.decode(bytes.dup)
  if response.error
    raise ClientError, "GetResponse error #{response.error.error_code}: #{response.error.error_message}"
  end
  raise KeyNotFound if response.versioned.nil? || response.versioned.empty?
  response.versioned.max{|a, b| a.version.timestamp <=> b.version.timestamp }.value
end