thrifty-bunny 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -10
- data/examples/calculator/{bin/client.start → client.start} +3 -2
- data/examples/calculator/{server.rb → server.start} +7 -1
- data/lib/thrifty_bunny/version.rb +1 -1
- metadata +3 -5
- data/examples/calculator/bin/server.start +0 -7
- data/examples/calculator/client.rb +0 -97
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5431a63a327ed1983ebfb9c6168eddb816bff81f
|
4
|
+
data.tar.gz: d86999a0d27b2cde313524d9660ad35c2bf729c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f0f112f8ca8cebbd6992036fbd98b30b7e34944fd06774df40c344d8b875d8201ed1a28d0e9f17390d128b9f6b5780352a850d3c67d17c2617b1cb024311e0
|
7
|
+
data.tar.gz: 6e5f728a9f61c35e6d7ef3275625101ff02f45bae524ce2e7d8ce35320bed2b1ca073251a3c61064e3a2a0fea882738675eb4426b901dfc93604682639e7eefe
|
data/README.md
CHANGED
@@ -66,25 +66,18 @@ An easy way to experiment with the gem is to take a look at the provided example
|
|
66
66
|
|
67
67
|
2. Start up two separate terminals
|
68
68
|
|
69
|
-
3.
|
69
|
+
3. In one terminal, start the server:
|
70
70
|
```
|
71
|
-
$
|
72
|
-
```
|
73
|
-
|
74
|
-
4. In one terminal, start the server:
|
75
|
-
```
|
76
|
-
$ bundle exec bin/server.start
|
71
|
+
$ bundle exec examples/calculator/server.start
|
77
72
|
```
|
78
73
|
|
79
74
|
5. In the other terminal, start the client:
|
80
75
|
```
|
81
|
-
$ bundle exec
|
76
|
+
$ bundle exec examples/calculator/client.start
|
82
77
|
```
|
83
78
|
|
84
79
|
6. In the [RabbitMQ admin console](http://localhost:15672), you can monitor the message queues.
|
85
80
|
|
86
|
-
The client prompts you to enter a name, then the servers respond by saying hello to you. Feel free to start up additional servers to demonstrate how the system scales.
|
87
|
-
|
88
81
|
## Contributing
|
89
82
|
|
90
83
|
1. Fork it ( https://github.com/[my-github-username]/thrifty-bunny/fork )
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require 'thrifty_bunny'
|
3
|
+
require_relative 'calculator_service'
|
3
4
|
|
4
5
|
class ClientCli
|
5
6
|
|
@@ -43,7 +44,7 @@ end
|
|
43
44
|
|
44
45
|
transport = ThriftyBunny::ClientTransport.new
|
45
46
|
protocol = Thrift::BinaryProtocol.new(transport)
|
46
|
-
client =
|
47
|
+
client = CalculatorService::Client.new(protocol)
|
47
48
|
client_cli = ClientCli.new(client)
|
48
49
|
|
49
50
|
loop do
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
require 'thrifty_bunny'
|
2
3
|
require_relative 'calculator_service'
|
3
4
|
|
@@ -33,4 +34,9 @@ module Calculator
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
end
|
37
|
+
end
|
38
|
+
|
39
|
+
server = Calculator::Server.new
|
40
|
+
puts "Starting server ..."
|
41
|
+
server.serve
|
42
|
+
puts "Done."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bill Siggelkow
|
@@ -134,12 +134,10 @@ files:
|
|
134
134
|
- LICENSE.txt
|
135
135
|
- README.md
|
136
136
|
- Rakefile
|
137
|
-
- examples/calculator/bin/client.start
|
138
|
-
- examples/calculator/bin/server.start
|
139
137
|
- examples/calculator/calculator_service.rb
|
140
138
|
- examples/calculator/calculator_service.thrift
|
141
|
-
- examples/calculator/client.
|
142
|
-
- examples/calculator/server.
|
139
|
+
- examples/calculator/client.start
|
140
|
+
- examples/calculator/server.start
|
143
141
|
- lib/thrifty_bunny.rb
|
144
142
|
- lib/thrifty_bunny/client_transport.rb
|
145
143
|
- lib/thrifty_bunny/config.rb
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'thrifty_bunny'
|
2
|
-
require_relative 'calculator_service'
|
3
|
-
|
4
|
-
module Calculator
|
5
|
-
|
6
|
-
class Client < CalculatorService::Client
|
7
|
-
|
8
|
-
# def initialize(options={})
|
9
|
-
# @transport = ThriftyBunny::ClientTransport.new
|
10
|
-
# protocol = Thrift::BinaryProtocol.new(@transport)
|
11
|
-
# @client = CalculatorService::Client.new(protocol)
|
12
|
-
# end
|
13
|
-
|
14
|
-
# def say_hello(name)
|
15
|
-
# safe_transport do
|
16
|
-
# @client.say_hello(name)
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
|
20
|
-
# private
|
21
|
-
|
22
|
-
# def safe_transport
|
23
|
-
# begin
|
24
|
-
# @transport.open
|
25
|
-
# return yield
|
26
|
-
# rescue ThriftyBunny::ResponseTimeout => e
|
27
|
-
# puts e
|
28
|
-
# ensure
|
29
|
-
# @transport.close
|
30
|
-
# end
|
31
|
-
# end
|
32
|
-
|
33
|
-
# def send_message(name, args_class, args = {})
|
34
|
-
# @oprot.write_message_begin(name, Thrift::MessageTypes::CALL, @seqid)
|
35
|
-
# data = args_class.new
|
36
|
-
# fld = 1
|
37
|
-
|
38
|
-
# args.each do |k, v|
|
39
|
-
|
40
|
-
# if data.struct_fields[fld][:type] == Thrift::Types::STRUCT and data.struct_fields[fld][:class] == JsonData
|
41
|
-
# res = Json_data.new()
|
42
|
-
# res.data = JSON.generate(v)
|
43
|
-
# v = res
|
44
|
-
# end
|
45
|
-
|
46
|
-
# data.send("#{k.to_s}=", v)
|
47
|
-
# fld += 1
|
48
|
-
# end
|
49
|
-
# begin
|
50
|
-
# data.write(@oprot)
|
51
|
-
# rescue StandardError => e
|
52
|
-
# @oprot.trans.close
|
53
|
-
# raise e
|
54
|
-
# end
|
55
|
-
# @oprot.write_message_end
|
56
|
-
|
57
|
-
# #If the oneway modifier is used in the thrift definition, then the recv_ version of the methods will
|
58
|
-
# #not be generated, so if it does not exist then no need to wait for a response.
|
59
|
-
# blocking_call = self.respond_to?("recv_" + name)
|
60
|
-
|
61
|
-
# @oprot.trans.flush(:operation => name,
|
62
|
-
# :blocking => blocking_call,
|
63
|
-
# :log_messages => true)
|
64
|
-
|
65
|
-
# end
|
66
|
-
|
67
|
-
# def receive_message(result_klass)
|
68
|
-
# fname, mtype, rseqid = @iprot.read_message_begin
|
69
|
-
# handle_exception(mtype)
|
70
|
-
# result = result_klass.new
|
71
|
-
# result.read(@iprot)
|
72
|
-
# @iprot.read_message_end
|
73
|
-
|
74
|
-
# if result.respond_to?(:success) and result.success.class == JsonData and
|
75
|
-
# result.struct_fields[0][:type] == Thrift::Types::STRUCT and result.struct_fields[0][:class] == JsonData
|
76
|
-
# json_res = JSON.parse(result.success.data)
|
77
|
-
|
78
|
-
# result.success = json_res
|
79
|
-
# end
|
80
|
-
|
81
|
-
# result
|
82
|
-
|
83
|
-
# end
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
# client = HelloThrift::Client.new
|
91
|
-
|
92
|
-
# loop do
|
93
|
-
# print "What is your name? "
|
94
|
-
# input = gets.strip
|
95
|
-
# break if input == 'quit'
|
96
|
-
# puts client.say_hello(input)
|
97
|
-
# end
|