Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 1 | # |
| 2 | # Autogenerated by Thrift |
| 3 | # |
| 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 5 | # |
| 6 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 7 | require 'thrift' |
Kevin Clark | 3836f9b | 2008-06-24 01:05:51 +0000 | [diff] [blame] | 8 | require 'thrift/protocol' |
Kevin Clark | 2bd3a30 | 2008-06-26 17:49:49 +0000 | [diff] [blame] | 9 | require File.dirname(__FILE__) + '/Benchmark_types' |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 10 | |
| 11 | module ThriftBenchmark |
| 12 | module BenchmarkService |
| 13 | class Client |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 14 | include ::Thrift::Client |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 15 | |
| 16 | def fibonacci(n) |
| 17 | send_fibonacci(n) |
| 18 | return recv_fibonacci() |
| 19 | end |
| 20 | |
| 21 | def send_fibonacci(n) |
| 22 | send_message('fibonacci', Fibonacci_args, :n => n) |
| 23 | end |
| 24 | |
| 25 | def recv_fibonacci() |
| 26 | result = receive_message(Fibonacci_result) |
| 27 | return result.success unless result.success.nil? |
| 28 | raise Thrift::ApplicationException.new(Thrift::ApplicationException::MISSING_RESULT, 'fibonacci failed: unknown result') |
| 29 | end |
| 30 | |
| 31 | end |
| 32 | |
| 33 | class Processor |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 34 | include ::Thrift::Processor |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 35 | |
| 36 | def process_fibonacci(seqid, iprot, oprot) |
| 37 | args = read_args(iprot, Fibonacci_args) |
| 38 | result = Fibonacci_result.new() |
| 39 | result.success = @handler.fibonacci(args.n) |
| 40 | write_result(result, oprot, 'fibonacci', seqid) |
| 41 | end |
| 42 | |
| 43 | end |
| 44 | |
| 45 | # HELPER FUNCTIONS AND STRUCTURES |
| 46 | |
| 47 | class Fibonacci_args |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 48 | include ::Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 49 | N = 1 |
| 50 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 51 | Thrift::Struct.field_accessor self, :n |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 52 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 53 | N => {:type => Thrift::Types::BYTE, :name => 'n'} |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 54 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 55 | |
| 56 | def struct_fields; FIELDS; end |
| 57 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 58 | def validate |
| 59 | end |
| 60 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 61 | end |
| 62 | |
| 63 | class Fibonacci_result |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 64 | include ::Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 65 | SUCCESS = 0 |
| 66 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 67 | Thrift::Struct.field_accessor self, :success |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 68 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 69 | SUCCESS => {:type => Thrift::Types::I32, :name => 'success'} |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 70 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 71 | |
| 72 | def struct_fields; FIELDS; end |
| 73 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 74 | def validate |
| 75 | end |
| 76 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 77 | end |
| 78 | |
| 79 | end |
| 80 | |
| 81 | end |