routemaster-drain 2.5.0 → 2.5.1

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: 174d544b122fdee4b52eb706ce2d1324e416eea4
4
- data.tar.gz: 2d33ba614a48f0e613adc1941a2126d17354b2a0
3
+ metadata.gz: 7a8ad60bfee0918ed21059151f9766548347337c
4
+ data.tar.gz: b6522a49633aca5590802c36cb072cec0d667fd4
5
5
  SHA512:
6
- metadata.gz: 0b3cc42bfe4e62e6ecc2b60e71c69525d669447c0601ea5bf06a1b79c1fdab7b6c1e20e1494acb980ac5097615231b2b22fda210cca1fc43b5fd87875667d453
7
- data.tar.gz: 4688fb67eb80241cf5fe28e5eed11be1617d083f8625fe378de960ee2506d45f105666ab556e69adb0944d592755d2ec9b302c31b6c8864ebdcc23070e02734d
6
+ metadata.gz: d05a881d29704c66cb409799d6de1503632f486be0a8b8dab6fd6012f824a170e5d96ab5827314094a10d5bb12e7b0579f7844cf48366743100f9d734ceae080
7
+ data.tar.gz: b574538c1c40e6c16c4d09fdb4ccacca3f6214f1b9088cdf4fa1de2d87d8b82fff1955ecf55b0e2208a8aaaa11a9db499f4dd32a73d4ad2ced5564a8c7e7e17b
data/.rubocop.yml CHANGED
@@ -716,7 +716,7 @@ Style/LineEndConcatenation:
716
716
  line end.
717
717
  Enabled: false
718
718
 
719
- Style/MethodCallParentheses:
719
+ Style/MethodCallWithoutArgsParentheses:
720
720
  Description: 'Do not use parentheses for method calls with no arguments.'
721
721
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
722
722
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ### 2.5.1 (2017-05-10)
2
+
3
+ Features:
4
+
5
+ - Adds the `Siphon` middleware to `CacheBusting` drain (#45)
6
+
7
+ Bug fixes:
8
+
9
+ - Sweep from dirty map if resource is missing (#47)
10
+
11
+
1
12
  ### 2.5.0 (2017-04-11)
2
13
 
3
14
  Features:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-drain (2.5.0)
4
+ routemaster-drain (2.5.1)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -37,7 +37,7 @@ GEM
37
37
  dotenv (2.1.1)
38
38
  ethon (0.10.1)
39
39
  ffi (>= 1.3.0)
40
- faraday (0.12.0.1)
40
+ faraday (0.12.1)
41
41
  multipart-post (>= 1.2, < 3)
42
42
  faraday_middleware (0.11.0.1)
43
43
  faraday (>= 0.7.4, < 1.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.0)
4
+ routemaster-drain (2.5.1)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -67,7 +67,7 @@ GEM
67
67
  erubis (2.7.0)
68
68
  ethon (0.10.1)
69
69
  ffi (>= 1.3.0)
70
- faraday (0.12.0.1)
70
+ faraday (0.12.1)
71
71
  multipart-post (>= 1.2, < 3)
72
72
  faraday_middleware (0.11.0.1)
73
73
  faraday (>= 0.7.4, < 1.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.0)
4
+ routemaster-drain (2.5.1)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -74,7 +74,7 @@ GEM
74
74
  erubis (2.7.0)
75
75
  ethon (0.10.1)
76
76
  ffi (>= 1.3.0)
77
- faraday (0.12.0.1)
77
+ faraday (0.12.1)
78
78
  multipart-post (>= 1.2, < 3)
79
79
  faraday_middleware (0.11.0.1)
80
80
  faraday (>= 0.7.4, < 1.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- routemaster-drain (2.5.0)
4
+ routemaster-drain (2.5.1)
5
5
  addressable
6
6
  concurrent-ruby
7
7
  faraday (>= 0.9.0)
@@ -77,7 +77,7 @@ GEM
77
77
  erubis (2.7.0)
78
78
  ethon (0.10.1)
79
79
  ffi (>= 1.3.0)
80
- faraday (0.12.0.1)
80
+ faraday (0.12.1)
81
81
  multipart-post (>= 1.2, < 3)
82
82
  faraday_middleware (0.11.0.1)
83
83
  faraday (>= 0.7.4, < 1.0)
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '2.5.0'
3
+ VERSION = '2.5.1'
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require 'routemaster/middleware/root_post_only'
2
2
  require 'routemaster/middleware/authenticate'
3
3
  require 'routemaster/middleware/parse'
4
+ require 'routemaster/middleware/siphon'
4
5
  require 'routemaster/middleware/expire_cache'
5
6
  require 'routemaster/middleware/payload_filter'
6
7
  require 'routemaster/middleware/filter'
@@ -25,6 +26,7 @@ module Routemaster
25
26
  use Middleware::RootPostOnly
26
27
  use Middleware::Authenticate, options
27
28
  use Middleware::Parse
29
+ use Middleware::Siphon, options
28
30
  use Middleware::Filter, { filter: Routemaster::Middleware::PayloadFilter.new }.merge(options)
29
31
  use Middleware::ExpireCache
30
32
  run terminator
@@ -11,7 +11,7 @@ module Routemaster
11
11
  begin
12
12
  Routemaster::Cache.new.get(url)
13
13
  rescue Errors::ResourceNotFound
14
- nil # nothing to cache
14
+ true # nothing to cache, remove the element from dirty
15
15
  end
16
16
  end
17
17
  end
@@ -18,6 +18,7 @@ module Routemaster
18
18
 
19
19
  def call(env)
20
20
  env['routemaster.dirty'] = dirty = []
21
+
21
22
  env.fetch('routemaster.payload', []).each do |event|
22
23
  next if event['type'] == 'noop'
23
24
  next unless @map.mark(event['url'])
@@ -3,6 +3,8 @@ require 'spec/support/rack_test'
3
3
  require 'spec/support/uses_redis'
4
4
  require 'spec/support/uses_dotenv'
5
5
  require 'spec/support/events'
6
+ require 'spec/support/siphon'
7
+
6
8
  require 'routemaster/drain/cache_busting'
7
9
  require 'json'
8
10
 
@@ -10,18 +12,21 @@ describe Routemaster::Drain::CacheBusting do
10
12
  uses_dotenv
11
13
  uses_redis
12
14
 
13
- let(:app) { described_class.new }
15
+ let(:app) { described_class.new options }
14
16
  let(:listener) { double 'listener' }
17
+ let(:options) { {} }
15
18
 
16
19
  before { app.subscribe(listener, prefix: true) }
17
20
 
18
21
  let(:path) { '/' }
19
- let(:payload) { [1,2,3,1].map { |idx| make_event(idx) }.to_json }
22
+ let(:payload) { [1,2,3,1].map { |idx| make_event(idx) } }
20
23
  let(:environment) {{ 'CONTENT_TYPE' => 'application/json' }}
21
- let(:perform) { post path, payload, environment }
24
+ let(:perform) { post path, payload.to_json, environment }
22
25
 
23
26
  before { authorize 'd3m0', 'x' }
24
27
 
28
+ include_examples 'supports siphon'
29
+
25
30
  it 'succeeds' do
26
31
  perform
27
32
  expect(last_response.status).to eq(204)
@@ -1,16 +1,29 @@
1
1
  require 'routemaster/jobs/cache_and_sweep'
2
+ require 'routemaster/dirty/map'
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Routemaster::Jobs::CacheAndSweep do
6
+ let(:url) { 'https://example.com/foo' }
7
+
5
8
  subject { described_class.new }
6
9
 
7
10
  context 'when there is an ResourceNotFound error' do
8
11
  before do
9
- expect_any_instance_of(Routemaster::Cache).to receive(:get).and_raise(Routemaster::Errors::ResourceNotFound.new(""))
12
+ allow_any_instance_of(Routemaster::Cache)
13
+ .to receive(:get)
14
+ .and_raise(Routemaster::Errors::ResourceNotFound.new(""))
10
15
  end
11
16
 
12
17
  it 'does not bubble up the error' do
13
- expect { subject.perform('url') }.to_not raise_error
18
+ expect { subject.perform(url) }.to_not raise_error
19
+ end
20
+
21
+ it 'sweeps the resource from the dirty map' do
22
+ expect_any_instance_of(Routemaster::Dirty::Map)
23
+ .to receive(:sweep_one)
24
+ .with(url) { |&block| expect(block.call).to eq true }
25
+
26
+ subject.perform(url)
14
27
  end
15
28
  end
16
29
 
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: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable