jp 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'fb303_types'
8
+
@@ -0,0 +1,18 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+
8
+ module Fb_status
9
+ DEAD = 0
10
+ STARTING = 1
11
+ ALIVE = 2
12
+ STOPPING = 3
13
+ STOPPED = 4
14
+ WARNING = 5
15
+ VALUE_MAP = {0 => "DEAD", 1 => "STARTING", 2 => "ALIVE", 3 => "STOPPING", 4 => "STOPPED", 5 => "WARNING"}
16
+ VALID_VALUES = Set.new([DEAD, STARTING, ALIVE, STOPPING, STOPPED, WARNING]).freeze
17
+ end
18
+
@@ -0,0 +1,218 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'facebook_service'
9
+ require 'jp_types'
10
+
11
+ module Jp
12
+ module JobPool
13
+ class Client < FacebookService::Client
14
+ include ::Thrift::Client
15
+
16
+ def add(pool_name, message)
17
+ send_add(pool_name, message)
18
+ recv_add()
19
+ end
20
+
21
+ def send_add(pool_name, message)
22
+ send_message('add', Add_args, :pool_name => pool_name, :message => message)
23
+ end
24
+
25
+ def recv_add()
26
+ result = receive_message(Add_result)
27
+ raise result.nsp unless result.nsp.nil?
28
+ return
29
+ end
30
+
31
+ def acquire(pool_name)
32
+ send_acquire(pool_name)
33
+ return recv_acquire()
34
+ end
35
+
36
+ def send_acquire(pool_name)
37
+ send_message('acquire', Acquire_args, :pool_name => pool_name)
38
+ end
39
+
40
+ def recv_acquire()
41
+ result = receive_message(Acquire_result)
42
+ return result.success unless result.success.nil?
43
+ raise result.nsp unless result.nsp.nil?
44
+ raise result.ep unless result.ep.nil?
45
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'acquire failed: unknown result')
46
+ end
47
+
48
+ def purge(pool_name, id)
49
+ send_purge(pool_name, id)
50
+ recv_purge()
51
+ end
52
+
53
+ def send_purge(pool_name, id)
54
+ send_message('purge', Purge_args, :pool_name => pool_name, :id => id)
55
+ end
56
+
57
+ def recv_purge()
58
+ result = receive_message(Purge_result)
59
+ raise result.nsp unless result.nsp.nil?
60
+ return
61
+ end
62
+
63
+ end
64
+
65
+ class Processor < FacebookService::Processor
66
+ include ::Thrift::Processor
67
+
68
+ def process_add(seqid, iprot, oprot)
69
+ args = read_args(iprot, Add_args)
70
+ result = Add_result.new()
71
+ begin
72
+ @handler.add(args.pool_name, args.message)
73
+ rescue Jp::NoSuchPool => nsp
74
+ result.nsp = nsp
75
+ end
76
+ write_result(result, oprot, 'add', seqid)
77
+ end
78
+
79
+ def process_acquire(seqid, iprot, oprot)
80
+ args = read_args(iprot, Acquire_args)
81
+ result = Acquire_result.new()
82
+ begin
83
+ result.success = @handler.acquire(args.pool_name)
84
+ rescue Jp::NoSuchPool => nsp
85
+ result.nsp = nsp
86
+ rescue Jp::EmptyPool => ep
87
+ result.ep = ep
88
+ end
89
+ write_result(result, oprot, 'acquire', seqid)
90
+ end
91
+
92
+ def process_purge(seqid, iprot, oprot)
93
+ args = read_args(iprot, Purge_args)
94
+ result = Purge_result.new()
95
+ begin
96
+ @handler.purge(args.pool_name, args.id)
97
+ rescue Jp::NoSuchPool => nsp
98
+ result.nsp = nsp
99
+ end
100
+ write_result(result, oprot, 'purge', seqid)
101
+ end
102
+
103
+ end
104
+
105
+ # HELPER FUNCTIONS AND STRUCTURES
106
+
107
+ class Add_args
108
+ include ::Thrift::Struct, ::Thrift::Struct_Union
109
+ POOL_NAME = 1
110
+ MESSAGE = 2
111
+
112
+ FIELDS = {
113
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'},
114
+ MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message', :binary => true}
115
+ }
116
+
117
+ def struct_fields; FIELDS; end
118
+
119
+ def validate
120
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
121
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field message is unset!') unless @message
122
+ end
123
+
124
+ ::Thrift::Struct.generate_accessors self
125
+ end
126
+
127
+ class Add_result
128
+ include ::Thrift::Struct, ::Thrift::Struct_Union
129
+ NSP = 1
130
+
131
+ FIELDS = {
132
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
133
+ }
134
+
135
+ def struct_fields; FIELDS; end
136
+
137
+ def validate
138
+ end
139
+
140
+ ::Thrift::Struct.generate_accessors self
141
+ end
142
+
143
+ class Acquire_args
144
+ include ::Thrift::Struct, ::Thrift::Struct_Union
145
+ POOL_NAME = 1
146
+
147
+ FIELDS = {
148
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'}
149
+ }
150
+
151
+ def struct_fields; FIELDS; end
152
+
153
+ def validate
154
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
155
+ end
156
+
157
+ ::Thrift::Struct.generate_accessors self
158
+ end
159
+
160
+ class Acquire_result
161
+ include ::Thrift::Struct, ::Thrift::Struct_Union
162
+ SUCCESS = 0
163
+ NSP = 1
164
+ EP = 2
165
+
166
+ FIELDS = {
167
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => Jp::Job},
168
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool},
169
+ EP => {:type => ::Thrift::Types::STRUCT, :name => 'ep', :class => Jp::EmptyPool}
170
+ }
171
+
172
+ def struct_fields; FIELDS; end
173
+
174
+ def validate
175
+ end
176
+
177
+ ::Thrift::Struct.generate_accessors self
178
+ end
179
+
180
+ class Purge_args
181
+ include ::Thrift::Struct, ::Thrift::Struct_Union
182
+ POOL_NAME = 1
183
+ ID = 2
184
+
185
+ FIELDS = {
186
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'},
187
+ ID => {:type => ::Thrift::Types::STRING, :name => 'id', :binary => true}
188
+ }
189
+
190
+ def struct_fields; FIELDS; end
191
+
192
+ def validate
193
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
194
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field id is unset!') unless @id
195
+ end
196
+
197
+ ::Thrift::Struct.generate_accessors self
198
+ end
199
+
200
+ class Purge_result
201
+ include ::Thrift::Struct, ::Thrift::Struct_Union
202
+ NSP = 1
203
+
204
+ FIELDS = {
205
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
206
+ }
207
+
208
+ def struct_fields; FIELDS; end
209
+
210
+ def validate
211
+ end
212
+
213
+ ::Thrift::Struct.generate_accessors self
214
+ end
215
+
216
+ end
217
+
218
+ end
@@ -0,0 +1,381 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'job_pool'
9
+ require 'jp_types'
10
+
11
+ module Jp
12
+ module JobPoolInstrumented
13
+ class Client < Jp::JobPool::Client
14
+ include ::Thrift::Client
15
+
16
+ def pools()
17
+ send_pools()
18
+ return recv_pools()
19
+ end
20
+
21
+ def send_pools()
22
+ send_message('pools', Pools_args)
23
+ end
24
+
25
+ def recv_pools()
26
+ result = receive_message(Pools_result)
27
+ return result.success unless result.success.nil?
28
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'pools failed: unknown result')
29
+ end
30
+
31
+ def start_time()
32
+ send_start_time()
33
+ return recv_start_time()
34
+ end
35
+
36
+ def send_start_time()
37
+ send_message('start_time', Start_time_args)
38
+ end
39
+
40
+ def recv_start_time()
41
+ result = receive_message(Start_time_result)
42
+ return result.success unless result.success.nil?
43
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'start_time failed: unknown result')
44
+ end
45
+
46
+ def add_count(pool_name)
47
+ send_add_count(pool_name)
48
+ return recv_add_count()
49
+ end
50
+
51
+ def send_add_count(pool_name)
52
+ send_message('add_count', Add_count_args, :pool_name => pool_name)
53
+ end
54
+
55
+ def recv_add_count()
56
+ result = receive_message(Add_count_result)
57
+ return result.success unless result.success.nil?
58
+ raise result.nsp unless result.nsp.nil?
59
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'add_count failed: unknown result')
60
+ end
61
+
62
+ def acquire_count(pool_name)
63
+ send_acquire_count(pool_name)
64
+ return recv_acquire_count()
65
+ end
66
+
67
+ def send_acquire_count(pool_name)
68
+ send_message('acquire_count', Acquire_count_args, :pool_name => pool_name)
69
+ end
70
+
71
+ def recv_acquire_count()
72
+ result = receive_message(Acquire_count_result)
73
+ return result.success unless result.success.nil?
74
+ raise result.nsp unless result.nsp.nil?
75
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'acquire_count failed: unknown result')
76
+ end
77
+
78
+ def empty_count(pool_name)
79
+ send_empty_count(pool_name)
80
+ return recv_empty_count()
81
+ end
82
+
83
+ def send_empty_count(pool_name)
84
+ send_message('empty_count', Empty_count_args, :pool_name => pool_name)
85
+ end
86
+
87
+ def recv_empty_count()
88
+ result = receive_message(Empty_count_result)
89
+ return result.success unless result.success.nil?
90
+ raise result.nsp unless result.nsp.nil?
91
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'empty_count failed: unknown result')
92
+ end
93
+
94
+ def purge_count(pool_name)
95
+ send_purge_count(pool_name)
96
+ return recv_purge_count()
97
+ end
98
+
99
+ def send_purge_count(pool_name)
100
+ send_message('purge_count', Purge_count_args, :pool_name => pool_name)
101
+ end
102
+
103
+ def recv_purge_count()
104
+ result = receive_message(Purge_count_result)
105
+ return result.success unless result.success.nil?
106
+ raise result.nsp unless result.nsp.nil?
107
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'purge_count failed: unknown result')
108
+ end
109
+
110
+ end
111
+
112
+ class Processor < Jp::JobPool::Processor
113
+ include ::Thrift::Processor
114
+
115
+ def process_pools(seqid, iprot, oprot)
116
+ args = read_args(iprot, Pools_args)
117
+ result = Pools_result.new()
118
+ result.success = @handler.pools()
119
+ write_result(result, oprot, 'pools', seqid)
120
+ end
121
+
122
+ def process_start_time(seqid, iprot, oprot)
123
+ args = read_args(iprot, Start_time_args)
124
+ result = Start_time_result.new()
125
+ result.success = @handler.start_time()
126
+ write_result(result, oprot, 'start_time', seqid)
127
+ end
128
+
129
+ def process_add_count(seqid, iprot, oprot)
130
+ args = read_args(iprot, Add_count_args)
131
+ result = Add_count_result.new()
132
+ begin
133
+ result.success = @handler.add_count(args.pool_name)
134
+ rescue Jp::NoSuchPool => nsp
135
+ result.nsp = nsp
136
+ end
137
+ write_result(result, oprot, 'add_count', seqid)
138
+ end
139
+
140
+ def process_acquire_count(seqid, iprot, oprot)
141
+ args = read_args(iprot, Acquire_count_args)
142
+ result = Acquire_count_result.new()
143
+ begin
144
+ result.success = @handler.acquire_count(args.pool_name)
145
+ rescue Jp::NoSuchPool => nsp
146
+ result.nsp = nsp
147
+ end
148
+ write_result(result, oprot, 'acquire_count', seqid)
149
+ end
150
+
151
+ def process_empty_count(seqid, iprot, oprot)
152
+ args = read_args(iprot, Empty_count_args)
153
+ result = Empty_count_result.new()
154
+ begin
155
+ result.success = @handler.empty_count(args.pool_name)
156
+ rescue Jp::NoSuchPool => nsp
157
+ result.nsp = nsp
158
+ end
159
+ write_result(result, oprot, 'empty_count', seqid)
160
+ end
161
+
162
+ def process_purge_count(seqid, iprot, oprot)
163
+ args = read_args(iprot, Purge_count_args)
164
+ result = Purge_count_result.new()
165
+ begin
166
+ result.success = @handler.purge_count(args.pool_name)
167
+ rescue Jp::NoSuchPool => nsp
168
+ result.nsp = nsp
169
+ end
170
+ write_result(result, oprot, 'purge_count', seqid)
171
+ end
172
+
173
+ end
174
+
175
+ # HELPER FUNCTIONS AND STRUCTURES
176
+
177
+ class Pools_args
178
+ include ::Thrift::Struct, ::Thrift::Struct_Union
179
+
180
+ FIELDS = {
181
+
182
+ }
183
+
184
+ def struct_fields; FIELDS; end
185
+
186
+ def validate
187
+ end
188
+
189
+ ::Thrift::Struct.generate_accessors self
190
+ end
191
+
192
+ class Pools_result
193
+ include ::Thrift::Struct, ::Thrift::Struct_Union
194
+ SUCCESS = 0
195
+
196
+ FIELDS = {
197
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRING}}
198
+ }
199
+
200
+ def struct_fields; FIELDS; end
201
+
202
+ def validate
203
+ end
204
+
205
+ ::Thrift::Struct.generate_accessors self
206
+ end
207
+
208
+ class Start_time_args
209
+ include ::Thrift::Struct, ::Thrift::Struct_Union
210
+
211
+ FIELDS = {
212
+
213
+ }
214
+
215
+ def struct_fields; FIELDS; end
216
+
217
+ def validate
218
+ end
219
+
220
+ ::Thrift::Struct.generate_accessors self
221
+ end
222
+
223
+ class Start_time_result
224
+ include ::Thrift::Struct, ::Thrift::Struct_Union
225
+ SUCCESS = 0
226
+
227
+ FIELDS = {
228
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
229
+ }
230
+
231
+ def struct_fields; FIELDS; end
232
+
233
+ def validate
234
+ end
235
+
236
+ ::Thrift::Struct.generate_accessors self
237
+ end
238
+
239
+ class Add_count_args
240
+ include ::Thrift::Struct, ::Thrift::Struct_Union
241
+ POOL_NAME = 1
242
+
243
+ FIELDS = {
244
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'}
245
+ }
246
+
247
+ def struct_fields; FIELDS; end
248
+
249
+ def validate
250
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
251
+ end
252
+
253
+ ::Thrift::Struct.generate_accessors self
254
+ end
255
+
256
+ class Add_count_result
257
+ include ::Thrift::Struct, ::Thrift::Struct_Union
258
+ SUCCESS = 0
259
+ NSP = 1
260
+
261
+ FIELDS = {
262
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'},
263
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
264
+ }
265
+
266
+ def struct_fields; FIELDS; end
267
+
268
+ def validate
269
+ end
270
+
271
+ ::Thrift::Struct.generate_accessors self
272
+ end
273
+
274
+ class Acquire_count_args
275
+ include ::Thrift::Struct, ::Thrift::Struct_Union
276
+ POOL_NAME = 1
277
+
278
+ FIELDS = {
279
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'}
280
+ }
281
+
282
+ def struct_fields; FIELDS; end
283
+
284
+ def validate
285
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
286
+ end
287
+
288
+ ::Thrift::Struct.generate_accessors self
289
+ end
290
+
291
+ class Acquire_count_result
292
+ include ::Thrift::Struct, ::Thrift::Struct_Union
293
+ SUCCESS = 0
294
+ NSP = 1
295
+
296
+ FIELDS = {
297
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'},
298
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
299
+ }
300
+
301
+ def struct_fields; FIELDS; end
302
+
303
+ def validate
304
+ end
305
+
306
+ ::Thrift::Struct.generate_accessors self
307
+ end
308
+
309
+ class Empty_count_args
310
+ include ::Thrift::Struct, ::Thrift::Struct_Union
311
+ POOL_NAME = 1
312
+
313
+ FIELDS = {
314
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'}
315
+ }
316
+
317
+ def struct_fields; FIELDS; end
318
+
319
+ def validate
320
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
321
+ end
322
+
323
+ ::Thrift::Struct.generate_accessors self
324
+ end
325
+
326
+ class Empty_count_result
327
+ include ::Thrift::Struct, ::Thrift::Struct_Union
328
+ SUCCESS = 0
329
+ NSP = 1
330
+
331
+ FIELDS = {
332
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'},
333
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
334
+ }
335
+
336
+ def struct_fields; FIELDS; end
337
+
338
+ def validate
339
+ end
340
+
341
+ ::Thrift::Struct.generate_accessors self
342
+ end
343
+
344
+ class Purge_count_args
345
+ include ::Thrift::Struct, ::Thrift::Struct_Union
346
+ POOL_NAME = 1
347
+
348
+ FIELDS = {
349
+ POOL_NAME => {:type => ::Thrift::Types::STRING, :name => 'pool_name'}
350
+ }
351
+
352
+ def struct_fields; FIELDS; end
353
+
354
+ def validate
355
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field pool_name is unset!') unless @pool_name
356
+ end
357
+
358
+ ::Thrift::Struct.generate_accessors self
359
+ end
360
+
361
+ class Purge_count_result
362
+ include ::Thrift::Struct, ::Thrift::Struct_Union
363
+ SUCCESS = 0
364
+ NSP = 1
365
+
366
+ FIELDS = {
367
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'},
368
+ NSP => {:type => ::Thrift::Types::STRUCT, :name => 'nsp', :class => Jp::NoSuchPool}
369
+ }
370
+
371
+ def struct_fields; FIELDS; end
372
+
373
+ def validate
374
+ end
375
+
376
+ ::Thrift::Struct.generate_accessors self
377
+ end
378
+
379
+ end
380
+
381
+ end