thrifty-bunny 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/examples/calculator/calculator_server.rb +36 -0
- data/examples/calculator/server.start +1 -35
- data/lib/thrifty_bunny/version.rb +1 -1
- data/spec/integration/client_spec.rb +26 -1
- data/spec/spec_helper.rb +3 -3
- data/thrifty-bunny.gemspec +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06937b3533e577afe5518bc7a80addc2e51d741e
|
4
|
+
data.tar.gz: 599f3c74544bc090e0038abd9f55d3702fa2f0bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d95984aa831e4d7024de6d8757515b67e0793680a7086e61d4e01a98e020f881124868950b762a6278807c6d8309aedc0df743953b906da609c317d23006061
|
7
|
+
data.tar.gz: f5a780e0e6efe7e45ef93c40c80059ef40a2631ef2687aa4cee17c0bad24a9934c3becc65c4da6d9f3f4054bd7c973fa6b69148f437401e5cc8987ec5bca2fc2
|
data/.gitignore
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thrifty_bunny'
|
2
|
+
require_relative 'calculator_service'
|
3
|
+
|
4
|
+
module Calculator
|
5
|
+
|
6
|
+
class Handler
|
7
|
+
def say_hello(name)
|
8
|
+
puts "Saying hello to #{name}"
|
9
|
+
"Hello, #{name} from Thrift!"
|
10
|
+
end
|
11
|
+
def add(value1, value2)
|
12
|
+
value1 + value2
|
13
|
+
end
|
14
|
+
def divide(dividend, divisor)
|
15
|
+
dividend.to_f / divisor.to_f
|
16
|
+
end
|
17
|
+
|
18
|
+
def ping
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Server
|
23
|
+
attr_reader :service
|
24
|
+
|
25
|
+
def initialize(options={})
|
26
|
+
handler = Handler.new
|
27
|
+
processor = CalculatorService::Processor.new(handler)
|
28
|
+
@service = ThriftyBunny::RpcServer.new(processor)
|
29
|
+
end
|
30
|
+
|
31
|
+
def serve
|
32
|
+
service.serve(log_messages: false, prefetch: 2)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -1,40 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'thrifty_bunny'
|
3
|
-
require_relative '
|
4
|
-
|
5
|
-
module Calculator
|
6
|
-
|
7
|
-
class Handler
|
8
|
-
def say_hello(name)
|
9
|
-
puts "Saying hello to #{name}"
|
10
|
-
"Hello, #{name} from Thrift!"
|
11
|
-
end
|
12
|
-
def add(value1, value2)
|
13
|
-
value1 + value2
|
14
|
-
end
|
15
|
-
def divide(dividend, divisor)
|
16
|
-
dividend.to_f / divisor.to_f
|
17
|
-
end
|
18
|
-
|
19
|
-
def ping
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Server
|
24
|
-
attr_reader :service
|
25
|
-
|
26
|
-
def initialize(options={})
|
27
|
-
handler = Handler.new
|
28
|
-
processor = CalculatorService::Processor.new(handler)
|
29
|
-
@service = ThriftyBunny::RpcServer.new(processor)
|
30
|
-
end
|
31
|
-
|
32
|
-
def serve
|
33
|
-
service.serve(log_messages: false, prefetch: 2)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
3
|
+
require_relative 'calculator_server'
|
38
4
|
|
39
5
|
server = Calculator::Server.new
|
40
6
|
puts "Starting server ..."
|
@@ -1,3 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'calculator_service'
|
3
|
+
require 'calculator_server'
|
4
|
+
|
2
5
|
describe 'client calls service' do
|
3
|
-
|
6
|
+
|
7
|
+
# Run the server in a forked sub-process
|
8
|
+
def launch_server
|
9
|
+
pid = fork do
|
10
|
+
puts "Starting server ..."
|
11
|
+
server = Calculator::Server.new
|
12
|
+
server.serve
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
launch_server
|
18
|
+
transport = ThriftyBunny::ClientTransport.new
|
19
|
+
protocol = Thrift::BinaryProtocol.new(transport)
|
20
|
+
@client = CalculatorService::Client.new(protocol)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'works' do
|
24
|
+
res = @client.say_hello('Bob')
|
25
|
+
expect(res).to eq("Hello, Bob from Thrift!")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path("
|
2
|
-
$LOAD_PATH.unshift File.expand_path("
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../examples/calculator", __FILE__)
|
3
3
|
|
4
4
|
require 'bundler'
|
5
5
|
Bundler.setup(:default, :test)
|
6
6
|
|
7
|
-
require 'thrifty_bunny'
|
7
|
+
require 'thrifty_bunny'
|
data/thrifty-bunny.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrifty-bunny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Siggelkow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: bunny
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.6.3
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.6.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: uuidtools
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- LICENSE.txt
|
135
135
|
- README.md
|
136
136
|
- Rakefile
|
137
|
+
- examples/calculator/calculator_server.rb
|
137
138
|
- examples/calculator/calculator_service.rb
|
138
139
|
- examples/calculator/calculator_service.thrift
|
139
140
|
- examples/calculator/client.start
|