Permalink
Browse files

generated ruby bindings for the thrift iface

  • Loading branch information...
1 parent 04fe900 commit 593f064cb1c5e77c867dc6a17fa7f1e173257111 Cliff Moon committed Jan 15, 2009
View
@@ -0,0 +1,203 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+require 'thrift'
+require 'thrift/protocol'
+require File.dirname(__FILE__) + '/dynomite_types'
+
+module Dynomite
+ class Client
+ include ::Thrift::Client
+
+ def get(key)
+ send_get(key)
+ return recv_get()
+ end
+
+ def send_get(key)
+ send_message('get', Get_args, :key => key)
+ end
+
+ def recv_get()
+ result = receive_message(Get_result)
+ return result.success unless result.success.nil?
+ raise result.fail unless result.fail.nil?
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get failed: unknown result')
+ end
+
+ def put(key, context, data)
+ send_put(key, context, data)
+ return recv_put()
+ end
+
+ def send_put(key, context, data)
+ send_message('put', Put_args, :key => key, :context => context, :data => data)
+ end
+
+ def recv_put()
+ result = receive_message(Put_result)
+ return result.success unless result.success.nil?
+ raise result.fail unless result.fail.nil?
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'put failed: unknown result')
+ end
+
+ def has(key)
+ send_has(key)
+ return recv_has()
+ end
+
+ def send_has(key)
+ send_message('has', Has_args, :key => key)
+ end
+
+ def recv_has()
+ result = receive_message(Has_result)
+ return result.success unless result.success.nil?
+ raise result.fail unless result.fail.nil?
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'has failed: unknown result')
+ end
+
+ def remove(key)
+ send_remove(key)
+ return recv_remove()
+ end
+
+ def send_remove(key)
+ send_message('remove', Remove_args, :key => key)
+ end
+
+ def recv_remove()
+ result = receive_message(Remove_result)
+ return result.success unless result.success.nil?
+ raise result.fail unless result.fail.nil?
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'remove failed: unknown result')
+ end
+
+ end
+
+ class Processor
+ include ::Thrift::Processor
+
+ def process_get(seqid, iprot, oprot)
+ args = read_args(iprot, Get_args)
+ result = Get_result.new()
+ begin
+ result.success = @handler.get(args.key)
+ rescue FailureException => fail
+ result.fail = fail
+ end
+ write_result(result, oprot, 'get', seqid)
+ end
+
+ def process_put(seqid, iprot, oprot)
+ args = read_args(iprot, Put_args)
+ result = Put_result.new()
+ begin
+ result.success = @handler.put(args.key, args.context, args.data)
+ rescue FailureException => fail
+ result.fail = fail
+ end
+ write_result(result, oprot, 'put', seqid)
+ end
+
+ def process_has(seqid, iprot, oprot)
+ args = read_args(iprot, Has_args)
+ result = Has_result.new()
+ begin
+ result.success = @handler.has(args.key)
+ rescue FailureException => fail
+ result.fail = fail
+ end
+ write_result(result, oprot, 'has', seqid)
+ end
+
+ def process_remove(seqid, iprot, oprot)
+ args = read_args(iprot, Remove_args)
+ result = Remove_result.new()
+ begin
+ result.success = @handler.remove(args.key)
+ rescue FailureException => fail
+ result.fail = fail
+ end
+ write_result(result, oprot, 'remove', seqid)
+ end
+
+ end
+
+ # HELPER FUNCTIONS AND STRUCTURES
+
+ class Get_args
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :key
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'key'}
+ }
+ end
+
+ class Get_result
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :success, :fail
+ FIELDS = {
+ 0 => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => GetResult},
+ 1 => {:type => ::Thrift::Types::STRUCT, :name => 'fail', :class => FailureException}
+ }
+ end
+
+ class Put_args
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :key, :context, :data
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'key'},
+ 2 => {:type => ::Thrift::Types::STRING, :name => 'context'},
+ 3 => {:type => ::Thrift::Types::STRING, :name => 'data'}
+ }
+ end
+
+ class Put_result
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :success, :fail
+ FIELDS = {
+ 0 => {:type => ::Thrift::Types::I32, :name => 'success'},
+ 1 => {:type => ::Thrift::Types::STRUCT, :name => 'fail', :class => FailureException}
+ }
+ end
+
+ class Has_args
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :key
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'key'}
+ }
+ end
+
+ class Has_result
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :success, :fail
+ FIELDS = {
+ 0 => {:type => ::Thrift::Types::I32, :name => 'success'},
+ 1 => {:type => ::Thrift::Types::STRUCT, :name => 'fail', :class => FailureException}
+ }
+ end
+
+ class Remove_args
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :key
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'key'}
+ }
+ end
+
+ class Remove_result
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :success, :fail
+ FIELDS = {
+ 0 => {:type => ::Thrift::Types::I32, :name => 'success'},
+ 1 => {:type => ::Thrift::Types::STRUCT, :name => 'fail', :class => FailureException}
+ }
+ end
+
+end
+
@@ -0,0 +1,9 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+require 'thrift/protocol'
+require File.dirname(__FILE__) + '/dynomite_types'
+
@@ -0,0 +1,30 @@
+#
+# Autogenerated by Thrift
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+
+require 'thrift/protocol'
+
+class GetResult
+ include ::Thrift::Struct
+ ::Thrift::Struct.field_accessor self, :context, :results
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'context'},
+ 2 => {:type => ::Thrift::Types::LIST, :name => 'results', :element => {:type => ::Thrift::Types::STRING}}
+ }
+end
+
+class FailureException < StandardError
+ include ::Thrift::Struct
+ def initialize(message=nil)
+ super()
+ self.message = message
+ end
+
+ ::Thrift::Struct.field_accessor self, :message
+ FIELDS = {
+ 1 => {:type => ::Thrift::Types::STRING, :name => 'message'}
+ }
+end
+
File renamed without changes.

0 comments on commit 593f064

Please sign in to comment.