routemaster-drain 1.0.4 → 1.0.5

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: e9452c2ba0c6f31936f6876817ee7d67ec770b2f
4
- data.tar.gz: 7eb4da8f25e7780b2cdef784a499d2c2407f6334
3
+ metadata.gz: c0272cbd5f92879aa1a44d0b928d5671db23568d
4
+ data.tar.gz: a0c52c2160834a7542817358896b2d25cb6adc6a
5
5
  SHA512:
6
- metadata.gz: 457ae9942fff794fbffc636263e4e1619f867badc0ba474ee217ffb48376aa40c4cfe887898eefe5fa1e2be44f64fe451a0677972e6a91336f0eeb6dc7459d02
7
- data.tar.gz: cf88b0164f7292afd1e46641c07f59f0489307d55b1b4f2dd4268e037b30c2c60ad4818156206853334fe25fb07261b5a243e54918030d6831584e2f6e7dbff1
6
+ metadata.gz: 265ccd4eaa6f7fdb28f59f5a104b631341bf2858cbd940bef9825eab39539f8fcf64dc9600ccc1470f047f5c2585ead66b1d5b5955fe377e3a479d5e38160df7
7
+ data.tar.gz: 6c98dbc0dc65777ed88cc223b36b0ffe2017918481cf1a675b696dc9f5331380725a5f05fe1bb4ebfecfd6878e05bdd8fee23a354e629d18deaa4eb01798a508
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-drain (1.0.4)
4
+ routemaster-drain (1.0.5)
5
5
  faraday (>= 0.9.0)
6
6
  faraday_middleware
7
7
  hashie
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '1.0.4'
3
+ VERSION = '1.0.5'
4
4
  end
5
5
  end
@@ -27,8 +27,7 @@ module Routemaster
27
27
  private
28
28
 
29
29
  def _check_for_fork
30
- return if Process.pid != @_pid
31
- _cleanup
30
+ _cleanup unless Process.pid == @_pid
32
31
  end
33
32
 
34
33
  def _cleanup
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../../lib/routemaster/redis_broker'
4
+
5
+ describe Routemaster::RedisBroker do
6
+ subject { Class.new(Routemaster::RedisBroker).instance }
7
+
8
+ describe "#get" do
9
+ let(:url) { 'redis://localhost/12' }
10
+
11
+ context "setting up a redis namespace" do
12
+ let(:redis) { instance_double(Redis) }
13
+ let(:redis_namespace) { instance_double(Redis::Namespace) }
14
+
15
+ before do
16
+ allow(Redis).to receive(:new) { redis }
17
+ allow(Redis::Namespace).to receive(:new) { redis_namespace }
18
+ end
19
+
20
+ it 'returns a namespaced redis connection' do
21
+ expect(subject.get(url)).to eq(redis_namespace)
22
+ end
23
+
24
+ it 'uses the url to initialise redis' do
25
+ expect(Redis).to receive(:new).with(url: url)
26
+ subject.get(url)
27
+ end
28
+
29
+ it 'namespaces with rm by default' do
30
+ expect(Redis::Namespace).to receive(:new).with('rm', redis: redis)
31
+ subject.get(url)
32
+ end
33
+
34
+ it 'can use a namespace based on the url' do
35
+ expect(Redis::Namespace).to receive(:new).with('other', redis: redis)
36
+ subject.get('redis://localhost/12/other')
37
+ end
38
+ end
39
+
40
+ context "when we are in the same process" do
41
+ it 'is a single connection for each url' do
42
+ expect(subject.get(url)).to eql(subject.get(url))
43
+ end
44
+ end
45
+
46
+ context "when we have forked" do
47
+ let!(:connection) { subject.get(url) }
48
+
49
+ it 'is a new connection for the newly forked process' do
50
+ # this is tied to implementation, but tests a 'fork' well enough
51
+ allow(Process).to receive(:pid) { -1 }
52
+ expect(subject.get(url)).to_not eql(connection)
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: routemaster-drain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-08 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -192,6 +192,7 @@ files:
192
192
  - spec/routemaster/middleware/filter_spec.rb
193
193
  - spec/routemaster/middleware/parse_spec.rb
194
194
  - spec/routemaster/middleware/root_post_only_spec.rb
195
+ - spec/routemaster/redis_broker_spec.rb
195
196
  - spec/spec_helper.rb
196
197
  - spec/support/events.rb
197
198
  - spec/support/rack_test.rb
@@ -239,6 +240,7 @@ test_files:
239
240
  - spec/routemaster/middleware/filter_spec.rb
240
241
  - spec/routemaster/middleware/parse_spec.rb
241
242
  - spec/routemaster/middleware/root_post_only_spec.rb
243
+ - spec/routemaster/redis_broker_spec.rb
242
244
  - spec/spec_helper.rb
243
245
  - spec/support/events.rb
244
246
  - spec/support/rack_test.rb