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 |
| 14 | include Thrift::Client |
| 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 |
| 34 | include Thrift::Processor |
| 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 |
| 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 | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame^] | 55 | def validate |
| 56 | end |
| 57 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 58 | end |
| 59 | |
| 60 | class Fibonacci_result |
| 61 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 62 | SUCCESS = 0 |
| 63 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 64 | Thrift::Struct.field_accessor self, :success |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 65 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 66 | SUCCESS => {:type => Thrift::Types::I32, :name => 'success'} |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 67 | } |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame^] | 68 | def validate |
| 69 | end |
| 70 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 71 | end |
| 72 | |
| 73 | end |
| 74 | |
| 75 | end |