Kevin Clark | e0fddde | 2008-06-18 01:16:02 +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 | e0fddde | 2008-06-18 01:16:02 +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__) + '/ThriftSpec_types' |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 10 | |
| 11 | module SpecNamespace |
| 12 | module NonblockingService |
| 13 | class Client |
| 14 | include Thrift::Client |
| 15 | |
| 16 | def greeting(english) |
| 17 | send_greeting(english) |
| 18 | return recv_greeting() |
| 19 | end |
| 20 | |
| 21 | def send_greeting(english) |
| 22 | send_message('greeting', Greeting_args, :english => english) |
| 23 | end |
| 24 | |
| 25 | def recv_greeting() |
| 26 | result = receive_message(Greeting_result) |
| 27 | return result.success unless result.success.nil? |
| 28 | raise Thrift::ApplicationException.new(Thrift::ApplicationException::MISSING_RESULT, 'greeting failed: unknown result') |
| 29 | end |
| 30 | |
| 31 | def block() |
| 32 | send_block() |
| 33 | return recv_block() |
| 34 | end |
| 35 | |
| 36 | def send_block() |
| 37 | send_message('block', Block_args) |
| 38 | end |
| 39 | |
| 40 | def recv_block() |
| 41 | result = receive_message(Block_result) |
| 42 | return result.success unless result.success.nil? |
| 43 | raise Thrift::ApplicationException.new(Thrift::ApplicationException::MISSING_RESULT, 'block failed: unknown result') |
| 44 | end |
| 45 | |
Kevin Clark | 980e445 | 2008-06-18 01:19:59 +0000 | [diff] [blame] | 46 | def unblock(n) |
| 47 | send_unblock(n) |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 48 | end |
| 49 | |
Kevin Clark | 980e445 | 2008-06-18 01:19:59 +0000 | [diff] [blame] | 50 | def send_unblock(n) |
| 51 | send_message('unblock', Unblock_args, :n => n) |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 52 | end |
| 53 | def shutdown() |
| 54 | send_shutdown() |
| 55 | end |
| 56 | |
| 57 | def send_shutdown() |
| 58 | send_message('shutdown', Shutdown_args) |
| 59 | end |
| 60 | def sleep(seconds) |
| 61 | send_sleep(seconds) |
| 62 | recv_sleep() |
| 63 | end |
| 64 | |
| 65 | def send_sleep(seconds) |
| 66 | send_message('sleep', Sleep_args, :seconds => seconds) |
| 67 | end |
| 68 | |
| 69 | def recv_sleep() |
| 70 | result = receive_message(Sleep_result) |
| 71 | return |
| 72 | end |
| 73 | |
| 74 | end |
| 75 | |
| 76 | class Processor |
| 77 | include Thrift::Processor |
| 78 | |
| 79 | def process_greeting(seqid, iprot, oprot) |
| 80 | args = read_args(iprot, Greeting_args) |
| 81 | result = Greeting_result.new() |
| 82 | result.success = @handler.greeting(args.english) |
| 83 | write_result(result, oprot, 'greeting', seqid) |
| 84 | end |
| 85 | |
| 86 | def process_block(seqid, iprot, oprot) |
| 87 | args = read_args(iprot, Block_args) |
| 88 | result = Block_result.new() |
| 89 | result.success = @handler.block() |
| 90 | write_result(result, oprot, 'block', seqid) |
| 91 | end |
| 92 | |
| 93 | def process_unblock(seqid, iprot, oprot) |
| 94 | args = read_args(iprot, Unblock_args) |
Kevin Clark | 980e445 | 2008-06-18 01:19:59 +0000 | [diff] [blame] | 95 | @handler.unblock(args.n) |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 96 | return |
| 97 | end |
| 98 | |
| 99 | def process_shutdown(seqid, iprot, oprot) |
| 100 | args = read_args(iprot, Shutdown_args) |
| 101 | @handler.shutdown() |
| 102 | return |
| 103 | end |
| 104 | |
| 105 | def process_sleep(seqid, iprot, oprot) |
| 106 | args = read_args(iprot, Sleep_args) |
| 107 | result = Sleep_result.new() |
| 108 | @handler.sleep(args.seconds) |
| 109 | write_result(result, oprot, 'sleep', seqid) |
| 110 | end |
| 111 | |
| 112 | end |
| 113 | |
| 114 | # HELPER FUNCTIONS AND STRUCTURES |
| 115 | |
| 116 | class Greeting_args |
| 117 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 118 | ENGLISH = 1 |
| 119 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 120 | Thrift::Struct.field_accessor self, :english |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 121 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 122 | ENGLISH => {:type => Thrift::Types::BOOL, :name => 'english'} |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 123 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 124 | |
| 125 | def struct_fields; FIELDS; end |
| 126 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 127 | def validate |
| 128 | end |
| 129 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 130 | end |
| 131 | |
| 132 | class Greeting_result |
| 133 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 134 | SUCCESS = 0 |
| 135 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 136 | Thrift::Struct.field_accessor self, :success |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 137 | FIELDS = { |
Kevin Clark | 41baeab | 2009-01-05 23:10:17 +0000 | [diff] [blame] | 138 | SUCCESS => {:type => Thrift::Types::STRUCT, :name => 'success', :class => SpecNamespace::Hello} |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 139 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 140 | |
| 141 | def struct_fields; FIELDS; end |
| 142 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 143 | def validate |
| 144 | end |
| 145 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 146 | end |
| 147 | |
| 148 | class Block_args |
| 149 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 150 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 151 | FIELDS = { |
| 152 | |
| 153 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 154 | |
| 155 | def struct_fields; FIELDS; end |
| 156 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 157 | def validate |
| 158 | end |
| 159 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 160 | end |
| 161 | |
| 162 | class Block_result |
| 163 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 164 | SUCCESS = 0 |
| 165 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 166 | Thrift::Struct.field_accessor self, :success |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 167 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 168 | SUCCESS => {:type => Thrift::Types::BOOL, :name => 'success'} |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 169 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 170 | |
| 171 | def struct_fields; FIELDS; end |
| 172 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 173 | def validate |
| 174 | end |
| 175 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 176 | end |
| 177 | |
| 178 | class Unblock_args |
| 179 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 180 | N = 1 |
| 181 | |
Kevin Clark | 980e445 | 2008-06-18 01:19:59 +0000 | [diff] [blame] | 182 | Thrift::Struct.field_accessor self, :n |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 183 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 184 | N => {:type => Thrift::Types::I32, :name => 'n'} |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 185 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 186 | |
| 187 | def struct_fields; FIELDS; end |
| 188 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 189 | def validate |
| 190 | end |
| 191 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 192 | end |
| 193 | |
| 194 | class Unblock_result |
| 195 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 196 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 197 | FIELDS = { |
| 198 | |
| 199 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 200 | |
| 201 | def struct_fields; FIELDS; end |
| 202 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 203 | def validate |
| 204 | end |
| 205 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 206 | end |
| 207 | |
| 208 | class Shutdown_args |
| 209 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 210 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 211 | FIELDS = { |
| 212 | |
| 213 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 214 | |
| 215 | def struct_fields; FIELDS; end |
| 216 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 217 | def validate |
| 218 | end |
| 219 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 220 | end |
| 221 | |
| 222 | class Shutdown_result |
| 223 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 224 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 225 | FIELDS = { |
| 226 | |
| 227 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 228 | |
| 229 | def struct_fields; FIELDS; end |
| 230 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 231 | def validate |
| 232 | end |
| 233 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 234 | end |
| 235 | |
| 236 | class Sleep_args |
| 237 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 238 | SECONDS = 1 |
| 239 | |
Kevin Clark | 2319375 | 2008-06-18 01:18:07 +0000 | [diff] [blame] | 240 | Thrift::Struct.field_accessor self, :seconds |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 241 | FIELDS = { |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 242 | SECONDS => {:type => Thrift::Types::DOUBLE, :name => 'seconds'} |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 243 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 244 | |
| 245 | def struct_fields; FIELDS; end |
| 246 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 247 | def validate |
| 248 | end |
| 249 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 250 | end |
| 251 | |
| 252 | class Sleep_result |
| 253 | include Thrift::Struct |
Kevin Clark | 7dc7f75 | 2008-10-16 19:15:20 +0000 | [diff] [blame] | 254 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 255 | FIELDS = { |
| 256 | |
| 257 | } |
Kevin Clark | d6b7182 | 2009-01-06 01:34:28 +0000 | [diff] [blame] | 258 | |
| 259 | def struct_fields; FIELDS; end |
| 260 | |
Kevin Clark | 159383f | 2008-11-11 05:46:04 +0000 | [diff] [blame] | 261 | def validate |
| 262 | end |
| 263 | |
Kevin Clark | e0fddde | 2008-06-18 01:16:02 +0000 | [diff] [blame] | 264 | end |
| 265 | |
| 266 | end |
| 267 | |
| 268 | end |