carrot_rpc 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f73f5b969d7493688ef3d27e5c25033da3ca1dbb
4
- data.tar.gz: 6acc6663440edbc5656743c7f65e5a0504624d47
3
+ metadata.gz: 97329124a088c7a7628e5613ce2059874097a8db
4
+ data.tar.gz: 216bf02e2bf6e657c1a3938329069af10f6380c2
5
5
  SHA512:
6
- metadata.gz: 89f7ba93bc81ebffc4a48e7b2bc5064d55e8221355ce0b82d478df387f5deab61e5889f7b0f2793c606b0cdebe5523dc2261db821a8a0f942bc630d990366a2e
7
- data.tar.gz: 8a754d6fc92c81227e00a8be6d6ef8311a6ab2f2a15eedc57304517855c3fc0c0a64c12110eb309fc0c20e39f9478a91f5efd953b7d03b98c2d98995d1f3e948
6
+ metadata.gz: 8f6171315d5e230225a1062be1e46d97fe102f942407c0725c8331734137be6428598d675021ff808a2428009397c2beee07031632dbc0745bcb1c5fd7b70864
7
+ data.tar.gz: 4abfd002d0ea5d4b5c5704dac547c0076143c2dcfbbc3c46a7cf030b6105d275977ec95c649778ea08269aaae5b310b73cf00948257e8ac7a48951af76cb0aa3
data/CHANGELOG.md CHANGED
@@ -47,6 +47,12 @@
47
47
  # Changelog
48
48
  All significant changes in the project are documented here.
49
49
 
50
+ ## v0.8.0
51
+ ### Enchancements
52
+ * Don't assume that Bunny already has a connection to RabbitMQ.
53
+ * Attempt to start Bunny for the servers
54
+ * This allows the implementing application to decide when to start the connection when using a forking web server
55
+
50
56
  ## v0.7.1
51
57
  ### Bug Fixes
52
58
  * [#40](https://github.com/C-S-D/carrot_rpc/pull/41) - Deletes Queues immediately after the last consumer is unsubscribed. Reduces memory load. API remains the same. - [@shamil614](https://github.com/C-S-D/carrot_rpc/pull/34)
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- ruby "2.2.3"
3
+ ruby "2.2.5"
4
4
  # Specify your gem's dependencies in carrot_rpc.gemspec
5
5
  gemspec
6
6
 
data/README.md CHANGED
@@ -43,7 +43,7 @@ Or install it yourself as:
43
43
  ## Configuration
44
44
  There's two modes for CarrotRpc: server and client. The server is run via command line, and the client is run in your ruby application during the request / response lifecycle (like your Rails Controller).
45
45
  ### Server
46
- The server is configured via command line and run in it's own process.
46
+ The server is configured via command line and run in it's own process. Note: the server process will attempt to start a connection with Bunny automatically.
47
47
 
48
48
  Carrot is easy to run via command line:
49
49
  ```bash
@@ -80,7 +80,7 @@ Clients are configured by initializing `CarrotRpc::Configuration`. The most comm
80
80
  CarrotRpc.configure do |config|
81
81
  # Required on the client to connect to RabbitMQ.
82
82
  # Bunny defaults to connecting to ENV['RABBITMQ_URL']. See Bunny docs.
83
- config.bunny = Bunny.new.start
83
+ config.bunny = Bunny.new
84
84
  # Set the log level. Ruby Logger Docs http://ruby-doc.org/stdlib-2.2.0/libdoc/logger/rdoc/Logger.html
85
85
  config.loglevel = Logger::INFO
86
86
  # Create a new logger or use the Rails logger.
@@ -102,6 +102,45 @@ CarrotRpc.configure do |config|
102
102
  end
103
103
  ```
104
104
 
105
+ Depending upon your webserver of choice you'll want to make sure that the conneciton to RabbitMQ via Bunny is made after the server Process forks because Bunny immediately threads after the `start()` method.
106
+
107
+ Here's an example of how to do so with Puma.
108
+
109
+ ```ruby
110
+ # config/puma.rb
111
+
112
+ on_worker_boot do
113
+ CarrotRpc.configure do |config|
114
+ # Each worker should have it's own connection to RabbitMQ.
115
+ config.bunny = Bunny.new
116
+ end
117
+ CarrotRpc.connect
118
+ end
119
+ ```
120
+
121
+ Similarly with Sidekiq
122
+ ```ruby
123
+ # config/initializers/sidekiq.rb
124
+
125
+ Sidekiq.configure_server do |config|
126
+ CarrotRpc.connect
127
+ end
128
+ ```
129
+
130
+ If you want to run RpcClient in the rails console, you'll want to make a connection only on Rails console start.
131
+ ```ruby
132
+ # config/application.rb
133
+
134
+ module FooApplication
135
+ class Application < Rails::Application
136
+ # Only attempt to connect with Bunny in the console!!!
137
+ console do
138
+ CarrotRpc.connect
139
+ end
140
+ end
141
+ end
142
+ ```
143
+
105
144
  ## Usage
106
145
  ### Writing Servers
107
146
  Carrot CLI will look for your servers in `app/servers` directory. This directory should not be autoloaded by the host application. Very important to declare the name of the queue with `queue_name`. The name must be the same as what's implemented in the `Client`.
@@ -37,6 +37,8 @@ class CarrotRpc::ServerRunner
37
37
 
38
38
  # Start the servers and the run loop.
39
39
  def run!
40
+ CarrotRpc.connect
41
+
40
42
  signal.trap
41
43
 
42
44
  pid.check
@@ -1,3 +1,3 @@
1
1
  module CarrotRpc
2
- VERSION = "0.7.1".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
data/lib/carrot_rpc.rb CHANGED
@@ -48,4 +48,11 @@ module CarrotRpc
48
48
  def self.configure
49
49
  yield configuration
50
50
  end
51
+
52
+ # Attempts to start a connection to the existing Bunny object.
53
+ # @return [Bunny::Session]
54
+ def self.connect
55
+ bunny = configuration.bunny
56
+ bunny.start unless bunny.open?
57
+ end
51
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrot_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Hamilton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-18 00:00:00.000000000 Z
12
+ date: 2016-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.4.5.1
198
+ rubygems_version: 2.4.8
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Remote Procedure Call (RPC) using the Bunny Gem over RabbitMQ