id_service 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/id_service/client.rb +3 -2
- data/lib/id_service/helpers.rb +18 -17
- data/lib/id_service/processor.rb +3 -2
- data/lib/id_service/server.rb +4 -0
- data/lib/id_service/version.rb +1 -1
- metadata +3 -3
data/lib/id_service/client.rb
CHANGED
@@ -8,6 +8,7 @@ require 'id_service/helpers'
|
|
8
8
|
module IdService
|
9
9
|
class Client
|
10
10
|
include ::Thrift::Client
|
11
|
+
include IdService::Helpers
|
11
12
|
|
12
13
|
def initialize(options = {})
|
13
14
|
options.symbolize_keys!
|
@@ -41,11 +42,11 @@ private
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def send_get_id()
|
44
|
-
send_message('get_id',
|
45
|
+
send_message('get_id', GetIdArgs)
|
45
46
|
end
|
46
47
|
|
47
48
|
def recv_get_id()
|
48
|
-
result = receive_message(
|
49
|
+
result = receive_message(GetIdResult)
|
49
50
|
return result.success unless result.success.nil?
|
50
51
|
raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'get_id failed: unknown result')
|
51
52
|
end
|
data/lib/id_service/helpers.rb
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
require 'thrift'
|
2
2
|
|
3
3
|
module IdService
|
4
|
-
|
5
|
-
|
4
|
+
module Helpers
|
5
|
+
class GetIdArgs
|
6
|
+
include ::Thrift::Struct
|
7
|
+
include ::Thrift::Struct_Union
|
6
8
|
|
7
|
-
|
9
|
+
FIELDS = {}
|
8
10
|
|
9
|
-
|
11
|
+
def struct_fields; FIELDS; end
|
10
12
|
|
11
|
-
|
13
|
+
def validate; end
|
12
14
|
|
13
|
-
|
15
|
+
::Thrift::Struct.generate_accessors self
|
14
16
|
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
class GetIdResult
|
19
|
+
include ::Thrift::Struct
|
20
|
+
include ::Thrift::Struct_Union
|
18
21
|
|
19
|
-
|
20
|
-
include ::Thrift::Struct, ::Thrift::Struct_Union
|
21
|
-
SUCCESS = 0
|
22
|
+
SUCCESS = 0
|
22
23
|
|
23
|
-
|
24
|
+
FIELDS = {
|
24
25
|
SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
|
25
|
-
|
26
|
+
}
|
26
27
|
|
27
|
-
|
28
|
+
def struct_fields; FIELDS; end
|
28
29
|
|
29
|
-
|
30
|
-
end
|
30
|
+
def validate; end
|
31
31
|
|
32
|
-
|
32
|
+
::Thrift::Struct.generate_accessors self
|
33
|
+
end
|
33
34
|
end
|
34
35
|
end
|
data/lib/id_service/processor.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module IdService
|
2
2
|
class Processor
|
3
3
|
include ::Thrift::Processor
|
4
|
+
include IdService::Helpers
|
4
5
|
|
5
6
|
def process_get_id(seqid, iprot, oprot)
|
6
|
-
args = read_args(iprot,
|
7
|
-
result =
|
7
|
+
args = read_args(iprot, GetIdArgs)
|
8
|
+
result = GetIdResult.new()
|
8
9
|
result.success = @handler.get_id()
|
9
10
|
write_result(result, oprot, 'get_id', seqid)
|
10
11
|
end
|
data/lib/id_service/server.rb
CHANGED
@@ -9,10 +9,14 @@ require 'id_generator'
|
|
9
9
|
|
10
10
|
module IdService
|
11
11
|
class Server < Thrift::SimpleServer
|
12
|
+
attr_reader :hostname, :port, :host, :worker, :debug
|
13
|
+
|
12
14
|
def initialize(options = {})
|
13
15
|
options.symbolize_keys!
|
14
16
|
options = default_options.merge(options)
|
15
17
|
|
18
|
+
options.each { |key, value| instance_variable_set('@' + key.to_s, value) }
|
19
|
+
|
16
20
|
@handler = IdGenerator.new(options)
|
17
21
|
@processor = IdService::Processor.new(@handler)
|
18
22
|
@server_transport = Thrift::ServerSocket.new(options[:hostname], options[:port].to_s)
|
data/lib/id_service/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: id_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thrift
|
@@ -159,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
segments:
|
161
161
|
- 0
|
162
|
-
hash:
|
162
|
+
hash: -1492159357958152786
|
163
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
164
|
none: false
|
165
165
|
requirements:
|