blob: dd6db04ecf3080e31539de051063e197290acda5 [file] [log] [blame]
Kevin Clarkca8a1b32008-06-18 01:17:06 +00001#
David Reissea2cba82009-03-30 21:35:00 +00002# 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 Clarkca8a1b32008-06-18 01:17:06 +000021# Autogenerated by Thrift
22#
23# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
24#
25
Kevin Clarkca8a1b32008-06-18 01:17:06 +000026require 'thrift'
Kevin Clark3836f9b2008-06-24 01:05:51 +000027require 'thrift/protocol'
Kevin Clark2bd3a302008-06-26 17:49:49 +000028require File.dirname(__FILE__) + '/Benchmark_types'
Kevin Clarkca8a1b32008-06-18 01:17:06 +000029
30 module ThriftBenchmark
31 module BenchmarkService
32 class Client
Kevin Clarkc2896082009-03-04 21:32:54 +000033 include ::Thrift::Client
Kevin Clarkca8a1b32008-06-18 01:17:06 +000034
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 Clarkc2896082009-03-04 21:32:54 +000053 include ::Thrift::Processor
Kevin Clarkca8a1b32008-06-18 01:17:06 +000054
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 Clarkc2896082009-03-04 21:32:54 +000067 include ::Thrift::Struct
Kevin Clark7dc7f752008-10-16 19:15:20 +000068 N = 1
69
Kevin Clark23193752008-06-18 01:18:07 +000070 Thrift::Struct.field_accessor self, :n
Kevin Clarkca8a1b32008-06-18 01:17:06 +000071 FIELDS = {
Kevin Clark7dc7f752008-10-16 19:15:20 +000072 N => {:type => Thrift::Types::BYTE, :name => 'n'}
Kevin Clarkca8a1b32008-06-18 01:17:06 +000073 }
Kevin Clarkd6b71822009-01-06 01:34:28 +000074
75 def struct_fields; FIELDS; end
76
Kevin Clark159383f2008-11-11 05:46:04 +000077 def validate
78 end
79
Kevin Clarkca8a1b32008-06-18 01:17:06 +000080 end
81
82 class Fibonacci_result
Kevin Clarkc2896082009-03-04 21:32:54 +000083 include ::Thrift::Struct
Kevin Clark7dc7f752008-10-16 19:15:20 +000084 SUCCESS = 0
85
Kevin Clark23193752008-06-18 01:18:07 +000086 Thrift::Struct.field_accessor self, :success
Kevin Clarkca8a1b32008-06-18 01:17:06 +000087 FIELDS = {
Kevin Clark7dc7f752008-10-16 19:15:20 +000088 SUCCESS => {:type => Thrift::Types::I32, :name => 'success'}
Kevin Clarkca8a1b32008-06-18 01:17:06 +000089 }
Kevin Clarkd6b71822009-01-06 01:34:28 +000090
91 def struct_fields; FIELDS; end
92
Kevin Clark159383f2008-11-11 05:46:04 +000093 def validate
94 end
95
Kevin Clarkca8a1b32008-06-18 01:17:06 +000096 end
97
98 end
99
100 end