flipper 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea1b15f3ff6a07841a2a56d57df8850cb2b0d99a
4
- data.tar.gz: 47a9731ed32255a3e4757953acc6cd9ef150f6fb
3
+ metadata.gz: 843f963e51439159d1fd4c6d27abefcbc091dd38
4
+ data.tar.gz: 96b4532f699e3d1dc61a399be98d2494b47b3f36
5
5
  SHA512:
6
- metadata.gz: 2e30588ec41798decb4c5046989591d970ad449f4bcff410be91da49c5ae4868b6f02c3edf6409356105de13baca25d6d147bb8c24f43086bace1f374b3e4f8e
7
- data.tar.gz: e905fbdd814ff3fdff84a9bc3c35d71f3850817981a27539e77dcedf23581846f08a80187577f244a0d4e87802b5c797439f436ec0b7376fba96a043cf2631a6
6
+ metadata.gz: 23146daa1a8eff45c01d065f00d0b101b7929ebda1635bfd2e902427ca8c13f98cd97920176d1855d3d9798e3db508c401bde42e40dd18c2960d0eb5034c9aee
7
+ data.tar.gz: c5943fff3072a0d9ddab4cb823270cc0c76b3f912a95f27d18053b03a73353a0bd0855437e3ab5a9f073df5d32b34d46531d65eec23619b2565ea02f9b75c6b5
@@ -1,3 +1,7 @@
1
+ ## 0.14.0
2
+
3
+ * Changed sync_interval to be seconds instead of milliseconds.
4
+
1
5
  ## 0.13.0
2
6
 
3
7
  ### Additions/Changes
@@ -20,8 +20,8 @@ module Flipper
20
20
  # local - The local flipper adapter that should serve reads.
21
21
  # remote - The remote flipper adpater that should serve writes and update
22
22
  # the local on an interval.
23
- # interval - The number of milliseconds between syncs from remote to
24
- # local. Default value is set in IntervalSynchronizer.
23
+ # interval - The Float or Integer number of seconds between syncs from
24
+ # remote to local. Default value is set in IntervalSynchronizer.
25
25
  def initialize(local, remote, options = {})
26
26
  @name = :sync
27
27
  @local = local
@@ -2,18 +2,18 @@ module Flipper
2
2
  module Adapters
3
3
  class Sync
4
4
  # Internal: Wraps a Synchronizer instance and only invokes it every
5
- # N milliseconds.
5
+ # N seconds.
6
6
  class IntervalSynchronizer
7
- # Private: Number of milliseconds between syncs (default: 10 seconds).
8
- DEFAULT_INTERVAL_MS = 10_000
7
+ # Private: Number of seconds between syncs (default: 10).
8
+ DEFAULT_INTERVAL = 10
9
9
 
10
10
  # Private
11
11
  def self.now_ms
12
12
  Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
13
13
  end
14
14
 
15
- # Public: The number of milliseconds between invocations of the
16
- # wrapped synchronizer.
15
+ # Public: The Float or Integer number of seconds between invocations of
16
+ # the wrapped synchronizer.
17
17
  attr_reader :interval
18
18
 
19
19
  # Public: Initializes a new interval synchronizer.
@@ -23,7 +23,7 @@ module Flipper
23
23
  # the wrapped synchronizer.
24
24
  def initialize(synchronizer, interval: nil)
25
25
  @synchronizer = synchronizer
26
- @interval = interval || DEFAULT_INTERVAL_MS
26
+ @interval = interval || DEFAULT_INTERVAL
27
27
  # TODO: add jitter to this so all processes booting at the same time
28
28
  # don't phone home at the same time.
29
29
  @last_sync_at = 0
@@ -41,7 +41,7 @@ module Flipper
41
41
  private
42
42
 
43
43
  def time_to_sync?
44
- (now_ms - @last_sync_at) >= @interval
44
+ ((now_ms - @last_sync_at) / 1_000.0) >= @interval
45
45
  end
46
46
 
47
47
  def now_ms
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.14.0'.freeze
3
3
  end
@@ -14,20 +14,20 @@ RSpec.describe Flipper::Adapters::Sync::IntervalSynchronizer do
14
14
  expect(events.size).to be(1)
15
15
  end
16
16
 
17
- it "only invokes wrapped synchronizer every interval milliseconds" do
17
+ it "only invokes wrapped synchronizer every interval seconds" do
18
18
  now = described_class.now_ms
19
19
  subject.call
20
20
  events.clear
21
21
 
22
22
  # move time to one millisecond less than last sync + interval
23
23
  1.upto(interval) do |i|
24
- allow(described_class).to receive(:now_ms).and_return(now + i - 1)
24
+ allow(described_class).to receive(:now_ms).and_return(now + (i * 1_000) - 1)
25
25
  subject.call
26
26
  end
27
27
  expect(events.size).to be(0)
28
28
 
29
- # move time to last sync + interval
30
- allow(described_class).to receive(:now_ms).and_return(now + interval)
29
+ # move time to last sync + interval in milliseconds
30
+ allow(described_class).to receive(:now_ms).and_return(now + (interval * 1_000))
31
31
  subject.call
32
32
  expect(events.size).to be(1)
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Feature flipper is the act of enabling/disabling features in your application,
14
14
  ideally without re-deploying or changing anything in your code base. Flipper makes