mobile_version_thrift_client 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/app_version_constants.rb +15 -0
- data/lib/app_version_types.rb +92 -0
- data/lib/mobile_version_thrift_client.rb +82 -0
- data/lib/remote_version_manage_service.rb +256 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 29bd3a40b152c9590639c69bfefbec046c5cc6cb
|
4
|
+
data.tar.gz: 652f47a9aee2062a8f65d59b6be4fc4e2776c6e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72ba6e052262af60b873bd6c230239e9c50e1aef9cc09bbbb1c1f00b38990f020a3229f26751abd9f4260fe060c8308243d93168515d1e8aa73ee02ba59f4375
|
7
|
+
data.tar.gz: 8c169b484bdf8c37384e5582fc5195b5103d833ab995d3b3432b1b943205a07e01b89db6382f541b479c23dac005a7a1877341465d8d31fea965ad3d624ce7be
|
@@ -0,0 +1,92 @@
|
|
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
|
+
module Mobile
|
10
|
+
module Version
|
11
|
+
module Thrift
|
12
|
+
class AppDefinition
|
13
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
14
|
+
APPID = 1
|
15
|
+
APPTYPE = 2
|
16
|
+
OSTYPE = 3
|
17
|
+
PACKAGENAME = 4
|
18
|
+
ITUNEID = 5
|
19
|
+
CHANNELID = 6
|
20
|
+
APPNAME = 7
|
21
|
+
APPDESC = 8
|
22
|
+
CERTIFICATEURL = 9
|
23
|
+
|
24
|
+
FIELDS = {
|
25
|
+
APPID => {:type => ::Thrift::Types::I32, :name => 'appId'},
|
26
|
+
APPTYPE => {:type => ::Thrift::Types::STRING, :name => 'appType', :optional => true},
|
27
|
+
OSTYPE => {:type => ::Thrift::Types::STRING, :name => 'osType', :optional => true},
|
28
|
+
PACKAGENAME => {:type => ::Thrift::Types::STRING, :name => 'packageName', :optional => true},
|
29
|
+
ITUNEID => {:type => ::Thrift::Types::STRING, :name => 'ituneId', :optional => true},
|
30
|
+
CHANNELID => {:type => ::Thrift::Types::STRING, :name => 'channelId', :optional => true},
|
31
|
+
APPNAME => {:type => ::Thrift::Types::STRING, :name => 'appName', :optional => true},
|
32
|
+
APPDESC => {:type => ::Thrift::Types::STRING, :name => 'appDesc', :optional => true},
|
33
|
+
CERTIFICATEURL => {:type => ::Thrift::Types::STRING, :name => 'certificateUrl', :optional => true}
|
34
|
+
}
|
35
|
+
|
36
|
+
def struct_fields; FIELDS; end
|
37
|
+
|
38
|
+
def validate
|
39
|
+
end
|
40
|
+
|
41
|
+
::Thrift::Struct.generate_accessors self
|
42
|
+
end
|
43
|
+
|
44
|
+
class UpgradeCheckResult
|
45
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
46
|
+
HASNEWVERSION = 1
|
47
|
+
VERSION = 2
|
48
|
+
DOWNLOAD = 3
|
49
|
+
FORCEUPDATE = 4
|
50
|
+
UPGRADEDESC = 5
|
51
|
+
UPGRADEDESCURL = 6
|
52
|
+
|
53
|
+
FIELDS = {
|
54
|
+
HASNEWVERSION => {:type => ::Thrift::Types::BOOL, :name => 'hasNewVersion'},
|
55
|
+
VERSION => {:type => ::Thrift::Types::STRING, :name => 'version', :optional => true},
|
56
|
+
DOWNLOAD => {:type => ::Thrift::Types::STRING, :name => 'download', :optional => true},
|
57
|
+
FORCEUPDATE => {:type => ::Thrift::Types::BOOL, :name => 'forceUpdate'},
|
58
|
+
UPGRADEDESC => {:type => ::Thrift::Types::STRING, :name => 'upgradeDesc', :optional => true},
|
59
|
+
UPGRADEDESCURL => {:type => ::Thrift::Types::STRING, :name => 'upgradeDescUrl', :optional => true}
|
60
|
+
}
|
61
|
+
|
62
|
+
def struct_fields; FIELDS; end
|
63
|
+
|
64
|
+
def validate
|
65
|
+
end
|
66
|
+
|
67
|
+
::Thrift::Struct.generate_accessors self
|
68
|
+
end
|
69
|
+
|
70
|
+
class TransferData
|
71
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
72
|
+
SUCCESS = 1
|
73
|
+
ERRORMSG = 2
|
74
|
+
CONTENT = 3
|
75
|
+
|
76
|
+
FIELDS = {
|
77
|
+
SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'},
|
78
|
+
ERRORMSG => {:type => ::Thrift::Types::STRING, :name => 'errorMsg', :optional => true},
|
79
|
+
CONTENT => {:type => ::Thrift::Types::STRING, :name => 'content', :optional => true}
|
80
|
+
}
|
81
|
+
|
82
|
+
def struct_fields; FIELDS; end
|
83
|
+
|
84
|
+
def validate
|
85
|
+
end
|
86
|
+
|
87
|
+
::Thrift::Struct.generate_accessors self
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'app_version_constants'
|
2
|
+
require 'remote_version_manage_service'
|
3
|
+
require 'app_version_types'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
module Mobile
|
7
|
+
module Version
|
8
|
+
module Thrift
|
9
|
+
DEFAULT_CONFIG = {
|
10
|
+
'protocol' => 'compact',
|
11
|
+
'transport' => 'socket',
|
12
|
+
'transport_warpper' => 'framed',
|
13
|
+
'size' => 1,
|
14
|
+
'timeout' => 30,
|
15
|
+
'test_on_borrow' => true,
|
16
|
+
'multiplexed' => false,
|
17
|
+
'poo_timeout' => 12
|
18
|
+
}
|
19
|
+
class LoggerFactory
|
20
|
+
@@logger = nil
|
21
|
+
def self.getLogger(name)
|
22
|
+
if @@logger.nil?
|
23
|
+
log_path = "../#{name}.log"
|
24
|
+
log_level = "error"
|
25
|
+
logger = Logger.new(log_path, 'daily')
|
26
|
+
logger.level = Logger::const_get(log_level.upcase)
|
27
|
+
@@logger = logger
|
28
|
+
end
|
29
|
+
@@logger
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class ThriftVersionManageService
|
34
|
+
def initialize(config = {})
|
35
|
+
if config['servers'].nil?
|
36
|
+
raise 'servers must be determined!'
|
37
|
+
return
|
38
|
+
end
|
39
|
+
config = DEFAULT_CONFIG.merge(config)
|
40
|
+
config['client_class'] = 'Mobile::Version::Thrift::RemoteVersionManageService::Client'
|
41
|
+
@thrift_client = ThriftClient.new(config)
|
42
|
+
@@logger = LoggerFactory.getLogger("mobile-version-client")
|
43
|
+
end
|
44
|
+
|
45
|
+
def destory
|
46
|
+
@@logger.error("before version manage thrift service destory!!")
|
47
|
+
begin
|
48
|
+
@thrift_client.destory
|
49
|
+
rescue Exception => e
|
50
|
+
@logger.error("version manage thrfit service destory error !#{e.message}" + "\n" + e.backtrace.join("\n"))
|
51
|
+
end
|
52
|
+
@logger.error("version manage thrift service destroyed!!")
|
53
|
+
end
|
54
|
+
|
55
|
+
def checkForUpgrade(app_definition={}, version=nil)
|
56
|
+
if app_definition['appId'].nil? || app_definition['appId'].to_i <= 0 || version.nil?
|
57
|
+
raise 'appId, version can not be null!'
|
58
|
+
end
|
59
|
+
app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
|
60
|
+
return @thrift_client.checkForUpgrade(app_definition_struct, version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def getSecurityToken(app_definition={}, version=nil)
|
64
|
+
app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
|
65
|
+
return @thrift_client.getSecurityToken(app_definition_struct, version)
|
66
|
+
end
|
67
|
+
|
68
|
+
def addAppProduct(app_definition={})
|
69
|
+
app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
|
70
|
+
return @thrift_client.addAppProduct(app_definition_struct)
|
71
|
+
end
|
72
|
+
|
73
|
+
def addAppHistory(app_definition={}, version=nil, apiVersion=1,downloadUrl=nil)
|
74
|
+
app_definition_struct = Mobile::Version::Thrift::AppDefinition.new(app_definition)
|
75
|
+
return @thrift_client.addAppHistory(app_definition_struct, version, apiVersion, downloadUrl)
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,256 @@
|
|
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 'app_version_types'
|
9
|
+
|
10
|
+
module Mobile
|
11
|
+
module Version
|
12
|
+
module Thrift
|
13
|
+
module RemoteVersionManageService
|
14
|
+
class Client
|
15
|
+
include ::Thrift::Client
|
16
|
+
|
17
|
+
def checkForUpgrade(app, version)
|
18
|
+
send_checkForUpgrade(app, version)
|
19
|
+
return recv_checkForUpgrade()
|
20
|
+
end
|
21
|
+
|
22
|
+
def send_checkForUpgrade(app, version)
|
23
|
+
send_message('checkForUpgrade', CheckForUpgrade_args, :app => app, :version => version)
|
24
|
+
end
|
25
|
+
|
26
|
+
def recv_checkForUpgrade()
|
27
|
+
result = receive_message(CheckForUpgrade_result)
|
28
|
+
return result.success unless result.success.nil?
|
29
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'checkForUpgrade failed: unknown result')
|
30
|
+
end
|
31
|
+
|
32
|
+
def getSecurityToken(app, version)
|
33
|
+
send_getSecurityToken(app, version)
|
34
|
+
return recv_getSecurityToken()
|
35
|
+
end
|
36
|
+
|
37
|
+
def send_getSecurityToken(app, version)
|
38
|
+
send_message('getSecurityToken', GetSecurityToken_args, :app => app, :version => version)
|
39
|
+
end
|
40
|
+
|
41
|
+
def recv_getSecurityToken()
|
42
|
+
result = receive_message(GetSecurityToken_result)
|
43
|
+
return result.success unless result.success.nil?
|
44
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSecurityToken failed: unknown result')
|
45
|
+
end
|
46
|
+
|
47
|
+
def addAppProduct(app)
|
48
|
+
send_addAppProduct(app)
|
49
|
+
return recv_addAppProduct()
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_addAppProduct(app)
|
53
|
+
send_message('addAppProduct', AddAppProduct_args, :app => app)
|
54
|
+
end
|
55
|
+
|
56
|
+
def recv_addAppProduct()
|
57
|
+
result = receive_message(AddAppProduct_result)
|
58
|
+
return result.success unless result.success.nil?
|
59
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'addAppProduct failed: unknown result')
|
60
|
+
end
|
61
|
+
|
62
|
+
def addAppHistory(app, version, apiVersion, downloadUrl)
|
63
|
+
send_addAppHistory(app, version, apiVersion, downloadUrl)
|
64
|
+
return recv_addAppHistory()
|
65
|
+
end
|
66
|
+
|
67
|
+
def send_addAppHistory(app, version, apiVersion, downloadUrl)
|
68
|
+
send_message('addAppHistory', AddAppHistory_args, :app => app, :version => version, :apiVersion => apiVersion, :downloadUrl => downloadUrl)
|
69
|
+
end
|
70
|
+
|
71
|
+
def recv_addAppHistory()
|
72
|
+
result = receive_message(AddAppHistory_result)
|
73
|
+
return result.success unless result.success.nil?
|
74
|
+
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'addAppHistory failed: unknown result')
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
class Processor
|
80
|
+
include ::Thrift::Processor
|
81
|
+
|
82
|
+
def process_checkForUpgrade(seqid, iprot, oprot)
|
83
|
+
args = read_args(iprot, CheckForUpgrade_args)
|
84
|
+
result = CheckForUpgrade_result.new()
|
85
|
+
result.success = @handler.checkForUpgrade(args.app, args.version)
|
86
|
+
write_result(result, oprot, 'checkForUpgrade', seqid)
|
87
|
+
end
|
88
|
+
|
89
|
+
def process_getSecurityToken(seqid, iprot, oprot)
|
90
|
+
args = read_args(iprot, GetSecurityToken_args)
|
91
|
+
result = GetSecurityToken_result.new()
|
92
|
+
result.success = @handler.getSecurityToken(args.app, args.version)
|
93
|
+
write_result(result, oprot, 'getSecurityToken', seqid)
|
94
|
+
end
|
95
|
+
|
96
|
+
def process_addAppProduct(seqid, iprot, oprot)
|
97
|
+
args = read_args(iprot, AddAppProduct_args)
|
98
|
+
result = AddAppProduct_result.new()
|
99
|
+
result.success = @handler.addAppProduct(args.app)
|
100
|
+
write_result(result, oprot, 'addAppProduct', seqid)
|
101
|
+
end
|
102
|
+
|
103
|
+
def process_addAppHistory(seqid, iprot, oprot)
|
104
|
+
args = read_args(iprot, AddAppHistory_args)
|
105
|
+
result = AddAppHistory_result.new()
|
106
|
+
result.success = @handler.addAppHistory(args.app, args.version, args.apiVersion, args.downloadUrl)
|
107
|
+
write_result(result, oprot, 'addAppHistory', seqid)
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
# HELPER FUNCTIONS AND STRUCTURES
|
113
|
+
|
114
|
+
class CheckForUpgrade_args
|
115
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
116
|
+
APP = 1
|
117
|
+
VERSION = 2
|
118
|
+
|
119
|
+
FIELDS = {
|
120
|
+
APP => {:type => ::Thrift::Types::STRUCT, :name => 'app', :class => ::Mobile::Version::Thrift::AppDefinition},
|
121
|
+
VERSION => {:type => ::Thrift::Types::STRING, :name => 'version'}
|
122
|
+
}
|
123
|
+
|
124
|
+
def struct_fields; FIELDS; end
|
125
|
+
|
126
|
+
def validate
|
127
|
+
end
|
128
|
+
|
129
|
+
::Thrift::Struct.generate_accessors self
|
130
|
+
end
|
131
|
+
|
132
|
+
class CheckForUpgrade_result
|
133
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
134
|
+
SUCCESS = 0
|
135
|
+
|
136
|
+
FIELDS = {
|
137
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Mobile::Version::Thrift::UpgradeCheckResult}
|
138
|
+
}
|
139
|
+
|
140
|
+
def struct_fields; FIELDS; end
|
141
|
+
|
142
|
+
def validate
|
143
|
+
end
|
144
|
+
|
145
|
+
::Thrift::Struct.generate_accessors self
|
146
|
+
end
|
147
|
+
|
148
|
+
class GetSecurityToken_args
|
149
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
150
|
+
APP = 1
|
151
|
+
VERSION = 2
|
152
|
+
|
153
|
+
FIELDS = {
|
154
|
+
APP => {:type => ::Thrift::Types::STRUCT, :name => 'app', :class => ::Mobile::Version::Thrift::AppDefinition},
|
155
|
+
VERSION => {:type => ::Thrift::Types::STRING, :name => 'version'}
|
156
|
+
}
|
157
|
+
|
158
|
+
def struct_fields; FIELDS; end
|
159
|
+
|
160
|
+
def validate
|
161
|
+
end
|
162
|
+
|
163
|
+
::Thrift::Struct.generate_accessors self
|
164
|
+
end
|
165
|
+
|
166
|
+
class GetSecurityToken_result
|
167
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
168
|
+
SUCCESS = 0
|
169
|
+
|
170
|
+
FIELDS = {
|
171
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Mobile::Version::Thrift::TransferData}
|
172
|
+
}
|
173
|
+
|
174
|
+
def struct_fields; FIELDS; end
|
175
|
+
|
176
|
+
def validate
|
177
|
+
end
|
178
|
+
|
179
|
+
::Thrift::Struct.generate_accessors self
|
180
|
+
end
|
181
|
+
|
182
|
+
class AddAppProduct_args
|
183
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
184
|
+
APP = 1
|
185
|
+
|
186
|
+
FIELDS = {
|
187
|
+
APP => {:type => ::Thrift::Types::STRUCT, :name => 'app', :class => ::Mobile::Version::Thrift::AppDefinition}
|
188
|
+
}
|
189
|
+
|
190
|
+
def struct_fields; FIELDS; end
|
191
|
+
|
192
|
+
def validate
|
193
|
+
end
|
194
|
+
|
195
|
+
::Thrift::Struct.generate_accessors self
|
196
|
+
end
|
197
|
+
|
198
|
+
class AddAppProduct_result
|
199
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
200
|
+
SUCCESS = 0
|
201
|
+
|
202
|
+
FIELDS = {
|
203
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Mobile::Version::Thrift::TransferData}
|
204
|
+
}
|
205
|
+
|
206
|
+
def struct_fields; FIELDS; end
|
207
|
+
|
208
|
+
def validate
|
209
|
+
end
|
210
|
+
|
211
|
+
::Thrift::Struct.generate_accessors self
|
212
|
+
end
|
213
|
+
|
214
|
+
class AddAppHistory_args
|
215
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
216
|
+
APP = 1
|
217
|
+
VERSION = 2
|
218
|
+
APIVERSION = 3
|
219
|
+
DOWNLOADURL = 4
|
220
|
+
|
221
|
+
FIELDS = {
|
222
|
+
APP => {:type => ::Thrift::Types::STRUCT, :name => 'app', :class => ::Mobile::Version::Thrift::AppDefinition},
|
223
|
+
VERSION => {:type => ::Thrift::Types::STRING, :name => 'version'},
|
224
|
+
APIVERSION => {:type => ::Thrift::Types::I32, :name => 'apiVersion'},
|
225
|
+
DOWNLOADURL => {:type => ::Thrift::Types::STRING, :name => 'downloadUrl'}
|
226
|
+
}
|
227
|
+
|
228
|
+
def struct_fields; FIELDS; end
|
229
|
+
|
230
|
+
def validate
|
231
|
+
end
|
232
|
+
|
233
|
+
::Thrift::Struct.generate_accessors self
|
234
|
+
end
|
235
|
+
|
236
|
+
class AddAppHistory_result
|
237
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
238
|
+
SUCCESS = 0
|
239
|
+
|
240
|
+
FIELDS = {
|
241
|
+
SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Mobile::Version::Thrift::TransferData}
|
242
|
+
}
|
243
|
+
|
244
|
+
def struct_fields; FIELDS; end
|
245
|
+
|
246
|
+
def validate
|
247
|
+
end
|
248
|
+
|
249
|
+
::Thrift::Struct.generate_accessors self
|
250
|
+
end
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobile_version_thrift_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/app_version_constants.rb
|
20
|
+
- lib/app_version_types.rb
|
21
|
+
- lib/remote_version_manage_service.rb
|
22
|
+
- lib/mobile_version_thrift_client.rb
|
23
|
+
homepage:
|
24
|
+
licenses: []
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.0.3
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: mobile_version_thrift_client is a thrift client of mobile-version
|
46
|
+
test_files: []
|