subscribe-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35737f3791f1f088f33896744a050440401f4422
4
+ data.tar.gz: 3aaddf0e4c0cfa352d13b15155bb8834e70bab1a
5
+ SHA512:
6
+ metadata.gz: d4dcf2874a54c42f2d43142536b5c99ef8f11c2d375f0940607f95ad5867e2798dc5cacc88bea271a026b6f643f6d55ee8993a02644167492ad8fa07c6a2c7be
7
+ data.tar.gz: 9809354bce60ba61dc23ff6a12dd8ef486667117849c9141d5650592d9b849aeca15e8574f5e8072e9db3755257c57b072fb7ab3ba626deac6fde70b1c113567
@@ -0,0 +1,410 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'subscribe_types'
9
+
10
+ module ISubscribeHandler
11
+ class Client
12
+ include ::Thrift::Client
13
+
14
+ def getSubscriptions(uid)
15
+ send_getSubscriptions(uid)
16
+ return recv_getSubscriptions()
17
+ end
18
+
19
+ def send_getSubscriptions(uid)
20
+ send_message('getSubscriptions', GetSubscriptions_args, :uid => uid)
21
+ end
22
+
23
+ def recv_getSubscriptions()
24
+ result = receive_message(GetSubscriptions_result)
25
+ return result.success unless result.success.nil?
26
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSubscriptions failed: unknown result')
27
+ end
28
+
29
+ def subscribe(uid, albumId)
30
+ send_subscribe(uid, albumId)
31
+ return recv_subscribe()
32
+ end
33
+
34
+ def send_subscribe(uid, albumId)
35
+ send_message('subscribe', Subscribe_args, :uid => uid, :albumId => albumId)
36
+ end
37
+
38
+ def recv_subscribe()
39
+ result = receive_message(Subscribe_result)
40
+ return result.success unless result.success.nil?
41
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'subscribe failed: unknown result')
42
+ end
43
+
44
+ def unsubscribe(uid, albumId)
45
+ send_unsubscribe(uid, albumId)
46
+ return recv_unsubscribe()
47
+ end
48
+
49
+ def send_unsubscribe(uid, albumId)
50
+ send_message('unsubscribe', Unsubscribe_args, :uid => uid, :albumId => albumId)
51
+ end
52
+
53
+ def recv_unsubscribe()
54
+ result = receive_message(Unsubscribe_result)
55
+ return result.success unless result.success.nil?
56
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'unsubscribe failed: unknown result')
57
+ end
58
+
59
+ def checkAlbum(uid, albumId)
60
+ send_checkAlbum(uid, albumId)
61
+ return recv_checkAlbum()
62
+ end
63
+
64
+ def send_checkAlbum(uid, albumId)
65
+ send_message('checkAlbum', CheckAlbum_args, :uid => uid, :albumId => albumId)
66
+ end
67
+
68
+ def recv_checkAlbum()
69
+ result = receive_message(CheckAlbum_result)
70
+ return result.success unless result.success.nil?
71
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkAlbum failed: unknown result')
72
+ end
73
+
74
+ def checkSubscribeFlag(uid)
75
+ send_checkSubscribeFlag(uid)
76
+ return recv_checkSubscribeFlag()
77
+ end
78
+
79
+ def send_checkSubscribeFlag(uid)
80
+ send_message('checkSubscribeFlag', CheckSubscribeFlag_args, :uid => uid)
81
+ end
82
+
83
+ def recv_checkSubscribeFlag()
84
+ result = receive_message(CheckSubscribeFlag_result)
85
+ return result.success unless result.success.nil?
86
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkSubscribeFlag failed: unknown result')
87
+ end
88
+
89
+ def getSubscribeFlag(uid)
90
+ send_getSubscribeFlag(uid)
91
+ return recv_getSubscribeFlag()
92
+ end
93
+
94
+ def send_getSubscribeFlag(uid)
95
+ send_message('getSubscribeFlag', GetSubscribeFlag_args, :uid => uid)
96
+ end
97
+
98
+ def recv_getSubscribeFlag()
99
+ result = receive_message(GetSubscribeFlag_result)
100
+ return result.success unless result.success.nil?
101
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSubscribeFlag failed: unknown result')
102
+ end
103
+
104
+ def isSubscribe(uid, albumIds)
105
+ send_isSubscribe(uid, albumIds)
106
+ return recv_isSubscribe()
107
+ end
108
+
109
+ def send_isSubscribe(uid, albumIds)
110
+ send_message('isSubscribe', IsSubscribe_args, :uid => uid, :albumIds => albumIds)
111
+ end
112
+
113
+ def recv_isSubscribe()
114
+ result = receive_message(IsSubscribe_result)
115
+ return result.success unless result.success.nil?
116
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'isSubscribe failed: unknown result')
117
+ end
118
+
119
+ end
120
+
121
+ class Processor
122
+ include ::Thrift::Processor
123
+
124
+ def process_getSubscriptions(seqid, iprot, oprot)
125
+ args = read_args(iprot, GetSubscriptions_args)
126
+ result = GetSubscriptions_result.new()
127
+ result.success = @handler.getSubscriptions(args.uid)
128
+ write_result(result, oprot, 'getSubscriptions', seqid)
129
+ end
130
+
131
+ def process_subscribe(seqid, iprot, oprot)
132
+ args = read_args(iprot, Subscribe_args)
133
+ result = Subscribe_result.new()
134
+ result.success = @handler.subscribe(args.uid, args.albumId)
135
+ write_result(result, oprot, 'subscribe', seqid)
136
+ end
137
+
138
+ def process_unsubscribe(seqid, iprot, oprot)
139
+ args = read_args(iprot, Unsubscribe_args)
140
+ result = Unsubscribe_result.new()
141
+ result.success = @handler.unsubscribe(args.uid, args.albumId)
142
+ write_result(result, oprot, 'unsubscribe', seqid)
143
+ end
144
+
145
+ def process_checkAlbum(seqid, iprot, oprot)
146
+ args = read_args(iprot, CheckAlbum_args)
147
+ result = CheckAlbum_result.new()
148
+ result.success = @handler.checkAlbum(args.uid, args.albumId)
149
+ write_result(result, oprot, 'checkAlbum', seqid)
150
+ end
151
+
152
+ def process_checkSubscribeFlag(seqid, iprot, oprot)
153
+ args = read_args(iprot, CheckSubscribeFlag_args)
154
+ result = CheckSubscribeFlag_result.new()
155
+ result.success = @handler.checkSubscribeFlag(args.uid)
156
+ write_result(result, oprot, 'checkSubscribeFlag', seqid)
157
+ end
158
+
159
+ def process_getSubscribeFlag(seqid, iprot, oprot)
160
+ args = read_args(iprot, GetSubscribeFlag_args)
161
+ result = GetSubscribeFlag_result.new()
162
+ result.success = @handler.getSubscribeFlag(args.uid)
163
+ write_result(result, oprot, 'getSubscribeFlag', seqid)
164
+ end
165
+
166
+ def process_isSubscribe(seqid, iprot, oprot)
167
+ args = read_args(iprot, IsSubscribe_args)
168
+ result = IsSubscribe_result.new()
169
+ result.success = @handler.isSubscribe(args.uid, args.albumIds)
170
+ write_result(result, oprot, 'isSubscribe', seqid)
171
+ end
172
+
173
+ end
174
+
175
+ # HELPER FUNCTIONS AND STRUCTURES
176
+
177
+ class GetSubscriptions_args
178
+ include ::Thrift::Struct, ::Thrift::Struct_Union
179
+ UID = 1
180
+
181
+ FIELDS = {
182
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'}
183
+ }
184
+
185
+ def struct_fields; FIELDS; end
186
+
187
+ def validate
188
+ end
189
+
190
+ ::Thrift::Struct.generate_accessors self
191
+ end
192
+
193
+ class GetSubscriptions_result
194
+ include ::Thrift::Struct, ::Thrift::Struct_Union
195
+ SUCCESS = 0
196
+
197
+ FIELDS = {
198
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::STRUCT, :class => ::Subscription}}
199
+ }
200
+
201
+ def struct_fields; FIELDS; end
202
+
203
+ def validate
204
+ end
205
+
206
+ ::Thrift::Struct.generate_accessors self
207
+ end
208
+
209
+ class Subscribe_args
210
+ include ::Thrift::Struct, ::Thrift::Struct_Union
211
+ UID = 1
212
+ ALBUMID = 2
213
+
214
+ FIELDS = {
215
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'},
216
+ ALBUMID => {:type => ::Thrift::Types::I64, :name => 'albumId'}
217
+ }
218
+
219
+ def struct_fields; FIELDS; end
220
+
221
+ def validate
222
+ end
223
+
224
+ ::Thrift::Struct.generate_accessors self
225
+ end
226
+
227
+ class Subscribe_result
228
+ include ::Thrift::Struct, ::Thrift::Struct_Union
229
+ SUCCESS = 0
230
+
231
+ FIELDS = {
232
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
233
+ }
234
+
235
+ def struct_fields; FIELDS; end
236
+
237
+ def validate
238
+ end
239
+
240
+ ::Thrift::Struct.generate_accessors self
241
+ end
242
+
243
+ class Unsubscribe_args
244
+ include ::Thrift::Struct, ::Thrift::Struct_Union
245
+ UID = 1
246
+ ALBUMID = 2
247
+
248
+ FIELDS = {
249
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'},
250
+ ALBUMID => {:type => ::Thrift::Types::I64, :name => 'albumId'}
251
+ }
252
+
253
+ def struct_fields; FIELDS; end
254
+
255
+ def validate
256
+ end
257
+
258
+ ::Thrift::Struct.generate_accessors self
259
+ end
260
+
261
+ class Unsubscribe_result
262
+ include ::Thrift::Struct, ::Thrift::Struct_Union
263
+ SUCCESS = 0
264
+
265
+ FIELDS = {
266
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
267
+ }
268
+
269
+ def struct_fields; FIELDS; end
270
+
271
+ def validate
272
+ end
273
+
274
+ ::Thrift::Struct.generate_accessors self
275
+ end
276
+
277
+ class CheckAlbum_args
278
+ include ::Thrift::Struct, ::Thrift::Struct_Union
279
+ UID = 1
280
+ ALBUMID = 2
281
+
282
+ FIELDS = {
283
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'},
284
+ ALBUMID => {:type => ::Thrift::Types::I64, :name => 'albumId'}
285
+ }
286
+
287
+ def struct_fields; FIELDS; end
288
+
289
+ def validate
290
+ end
291
+
292
+ ::Thrift::Struct.generate_accessors self
293
+ end
294
+
295
+ class CheckAlbum_result
296
+ include ::Thrift::Struct, ::Thrift::Struct_Union
297
+ SUCCESS = 0
298
+
299
+ FIELDS = {
300
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
301
+ }
302
+
303
+ def struct_fields; FIELDS; end
304
+
305
+ def validate
306
+ end
307
+
308
+ ::Thrift::Struct.generate_accessors self
309
+ end
310
+
311
+ class CheckSubscribeFlag_args
312
+ include ::Thrift::Struct, ::Thrift::Struct_Union
313
+ UID = 1
314
+
315
+ FIELDS = {
316
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'}
317
+ }
318
+
319
+ def struct_fields; FIELDS; end
320
+
321
+ def validate
322
+ end
323
+
324
+ ::Thrift::Struct.generate_accessors self
325
+ end
326
+
327
+ class CheckSubscribeFlag_result
328
+ include ::Thrift::Struct, ::Thrift::Struct_Union
329
+ SUCCESS = 0
330
+
331
+ FIELDS = {
332
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
333
+ }
334
+
335
+ def struct_fields; FIELDS; end
336
+
337
+ def validate
338
+ end
339
+
340
+ ::Thrift::Struct.generate_accessors self
341
+ end
342
+
343
+ class GetSubscribeFlag_args
344
+ include ::Thrift::Struct, ::Thrift::Struct_Union
345
+ UID = 1
346
+
347
+ FIELDS = {
348
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'}
349
+ }
350
+
351
+ def struct_fields; FIELDS; end
352
+
353
+ def validate
354
+ end
355
+
356
+ ::Thrift::Struct.generate_accessors self
357
+ end
358
+
359
+ class GetSubscribeFlag_result
360
+ include ::Thrift::Struct, ::Thrift::Struct_Union
361
+ SUCCESS = 0
362
+
363
+ FIELDS = {
364
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
365
+ }
366
+
367
+ def struct_fields; FIELDS; end
368
+
369
+ def validate
370
+ end
371
+
372
+ ::Thrift::Struct.generate_accessors self
373
+ end
374
+
375
+ class IsSubscribe_args
376
+ include ::Thrift::Struct, ::Thrift::Struct_Union
377
+ UID = 1
378
+ ALBUMIDS = 2
379
+
380
+ FIELDS = {
381
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'},
382
+ ALBUMIDS => {:type => ::Thrift::Types::LIST, :name => 'albumIds', :element => {:type => ::Thrift::Types::I64}}
383
+ }
384
+
385
+ def struct_fields; FIELDS; end
386
+
387
+ def validate
388
+ end
389
+
390
+ ::Thrift::Struct.generate_accessors self
391
+ end
392
+
393
+ class IsSubscribe_result
394
+ include ::Thrift::Struct, ::Thrift::Struct_Union
395
+ SUCCESS = 0
396
+
397
+ FIELDS = {
398
+ SUCCESS => {:type => ::Thrift::Types::LIST, :name => 'success', :element => {:type => ::Thrift::Types::BOOL}}
399
+ }
400
+
401
+ def struct_fields; FIELDS; end
402
+
403
+ def validate
404
+ end
405
+
406
+ ::Thrift::Struct.generate_accessors self
407
+ end
408
+
409
+ end
410
+
@@ -0,0 +1,3 @@
1
+ require 'i_subscribe_handler'
2
+ require 'subscribe_constants'
3
+ require 'subscribe_types'
@@ -0,0 +1,9 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'subscribe_types'
9
+
@@ -0,0 +1,34 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+
9
+ class Subscription
10
+ include ::Thrift::Struct, ::Thrift::Struct_Union
11
+ UID = 1
12
+ ALBUMID = 2
13
+ ALBUMTITLE = 3
14
+ ALBUMCOVER = 4
15
+ LASTCHECKAT = 5
16
+ LASTUPTRACKAT = 6
17
+
18
+ FIELDS = {
19
+ UID => {:type => ::Thrift::Types::I64, :name => 'uid'},
20
+ ALBUMID => {:type => ::Thrift::Types::I64, :name => 'albumId'},
21
+ ALBUMTITLE => {:type => ::Thrift::Types::STRING, :name => 'albumTitle'},
22
+ ALBUMCOVER => {:type => ::Thrift::Types::STRING, :name => 'albumCover'},
23
+ LASTCHECKAT => {:type => ::Thrift::Types::I64, :name => 'lastCheckAt'},
24
+ LASTUPTRACKAT => {:type => ::Thrift::Types::I64, :name => 'lastUptrackAt'}
25
+ }
26
+
27
+ def struct_fields; FIELDS; end
28
+
29
+ def validate
30
+ end
31
+
32
+ ::Thrift::Struct.generate_accessors self
33
+ end
34
+
@@ -0,0 +1,56 @@
1
+ $:.unshift File.expand_path("../../lib", __FILE__)
2
+ $:.unshift File.expand_path("../../test", __FILE__)
3
+
4
+ require "test/unit"
5
+ require 'thrift'
6
+ require "thrift_client"
7
+ require 'yaml'
8
+ require 'em-synchrony'
9
+ require 'subscribe'
10
+
11
+ class ClientTest < Test::Unit::TestCase
12
+ include Test::Unit::Assertions
13
+ def setup
14
+ super
15
+ root = File.expand_path("../..", __FILE__)
16
+ @config = YAML.load_file(File.join(root, 'test/thrift_config.yaml'))
17
+ puts "setup"
18
+ end
19
+
20
+ def test_client
21
+ EM.synchrony do
22
+ client = ThriftClient.new(@config['client_test'])
23
+ for i in 1 .. 1000
24
+ puts client.subscribe(1,i)
25
+ end
26
+ # puts client.isSubscribe(1,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
27
+ EM.stop
28
+ end
29
+ end
30
+
31
+ def test_GetSubscriptions
32
+
33
+ EM.synchrony do
34
+ client = ThriftClient.new(@config['client_test'])
35
+ for i in 1 .. 1000
36
+ subscriptions = client.getSubscriptions(1)
37
+ end
38
+ # puts client.isSubscribe(1,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])
39
+ EM.stop
40
+ end
41
+ end
42
+
43
+ def teardown
44
+ super
45
+ EM.synchrony do
46
+ client = ThriftClient.new(@config['client_test'])
47
+ subscriptions = client.getSubscriptions(1)
48
+ subscriptions.each { |subscription|
49
+ puts subscription.inspect
50
+ client.unsubscribe(subscription.id,subscription.uid,subscription.albumId)
51
+ }
52
+ EM.stop
53
+ end
54
+ puts "teardown"
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subscribe-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ted Wang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thrift-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.3
27
+ description: subscribe ruby client.
28
+ email: ted@ximalaya.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/i_subscribe_handler.rb
34
+ - lib/subscribe.rb
35
+ - lib/subscribe_constants.rb
36
+ - lib/subscribe_types.rb
37
+ - test/test_client.rb
38
+ homepage: http://www.ximalaya.com
39
+ licenses:
40
+ - MIT2.0
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.0.3
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: subscribe ruby client.
62
+ test_files:
63
+ - test/test_client.rb