Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 1 | # |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
| 20 | # |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 21 | # Autogenerated by Thrift |
| 22 | # |
| 23 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 24 | # |
| 25 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 26 | require 'thrift' |
Kevin Clark | 3836f9b | 2008-06-24 01:05:51 +0000 | [diff] [blame] | 27 | require 'thrift/protocol' |
Kevin Clark | 2bd3a30 | 2008-06-26 17:49:49 +0000 | [diff] [blame] | 28 | require File.dirname(__FILE__) + '/Benchmark_types' |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 29 | |
| 30 | module ThriftBenchmark |
| 31 | module BenchmarkService |
| 32 | class Client |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 33 | include ::Thrift::Client |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 34 | |
| 35 | def fibonacci(n) |
| 36 | send_fibonacci(n) |
| 37 | return recv_fibonacci() |
| 38 | end |
| 39 | |
| 40 | def send_fibonacci(n) |
| 41 | send_message('fibonacci', Fibonacci_args, :n => n) |
| 42 | end |
| 43 | |
| 44 | def recv_fibonacci() |
| 45 | result = receive_message(Fibonacci_result) |
| 46 | return result.success unless result.success.nil? |
| 47 | raise Thrift::ApplicationException.new(Thrift::ApplicationException::MISSING_RESULT, 'fibonacci failed: unknown result') |
| 48 | end |
| 49 | |
| 50 | end |
| 51 | |
| 52 | class Processor |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 53 | include ::Thrift::Processor |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 54 | |
| 55 | def process_fibonacci(seqid, iprot, oprot) |
| 56 | args = read_args(iprot, Fibonacci_args) |
| 57 | result = Fibonacci_result.new() |
| 58 | result.success = @handler.fibonacci(args.n) |
| 59 | write_result(result, oprot, 'fibonacci', seqid) |
| 60 | end |
| 61 | |
| 62 | end |
| 63 | |
| 64 | # HELPER FUNCTIONS AND STRUCTURES |
| 65 | |
| 66 | class Fibonacci_args |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 67 | include ::Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 68 | N = 1 |
| 69 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 70 | Thrift::Struct.field_accessor self, :n |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 71 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 72 | N => {:type => Thrift::Types::BYTE, :name => 'n'} |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 73 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 74 | |
| 75 | def struct_fields; FIELDS; end |
| 76 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 77 | def validate |
| 78 | end |
| 79 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 80 | end |
| 81 | |
| 82 | class Fibonacci_result |
Kevin Clark | c289608 | 2009-03-04 21:32:54 +0000 | [diff] [blame] | 83 | include ::Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 84 | SUCCESS = 0 |
| 85 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 86 | Thrift::Struct.field_accessor self, :success |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 87 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 88 | SUCCESS => {:type => Thrift::Types::I32, :name => 'success'} |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 89 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 90 | |
| 91 | def struct_fields; FIELDS; end |
| 92 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 93 | def validate |
| 94 | end |
| 95 | |
Kevin Clark | ca8a1b3 | 2008-06-18 01:17:06 +0000 | [diff] [blame] | 96 | end |
| 97 | |
| 98 | end |
| 99 | |
| 100 | end |