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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 843f963e51439159d1fd4c6d27abefcbc091dd38
|
4
|
+
data.tar.gz: 96b4532f699e3d1dc61a399be98d2494b47b3f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23146daa1a8eff45c01d065f00d0b101b7929ebda1635bfd2e902427ca8c13f98cd97920176d1855d3d9798e3db508c401bde42e40dd18c2960d0eb5034c9aee
|
7
|
+
data.tar.gz: c5943fff3072a0d9ddab4cb823270cc0c76b3f912a95f27d18053b03a73353a0bd0855437e3ab5a9f073df5d32b34d46531d65eec23619b2565ea02f9b75c6b5
|
data/Changelog.md
CHANGED
@@ -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
|
24
|
-
#
|
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
|
5
|
+
# N seconds.
|
6
6
|
class IntervalSynchronizer
|
7
|
-
# Private: Number of
|
8
|
-
|
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
|
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 ||
|
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
|
data/lib/flipper/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|