flipper 1.5.0.rc1 → 1.5.0.rc2
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 +4 -4
- data/lib/flipper/cloud/configuration.rb +15 -4
- data/lib/flipper/cloud/shared_memory.rb +36 -9
- data/lib/flipper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 28e85c4c99a54920a81f1fb1a1345e0d8e1492d149907636dbbf2d5218bad0eb
|
|
4
|
+
data.tar.gz: 1550707f666c820f6fa225637239b9084b87bddb69f5290755d8d4021e2be351
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e92e10677da51eb7a7da7336bd42aa9b37410f396dfbb04467d87c0ce390096781153f493270d52f8b46f6a0721e04e165416b6ec2968ea743106eb03d81f3f6
|
|
7
|
+
data.tar.gz: 8094d3cdb80b21bb47d7e4ab51886a9efe43e934341c3210513f885244922585cc9db352a546b8abb010cb7a70c563b80de3b4693d9631e437331c45a7551c11
|
|
@@ -136,7 +136,9 @@ module Flipper
|
|
|
136
136
|
# Fetch once for both the local adapter and memory.
|
|
137
137
|
snapshot = Flipper::Adapters::Memory.new(remote.get_all(cache_bust: cache_bust))
|
|
138
138
|
snapshot.sync_version = remote.sync_version
|
|
139
|
-
|
|
139
|
+
# Tracked like a poll's sync, so one that fails partway is synced again.
|
|
140
|
+
@memory.sync(snapshot.sync_version) { sync_memory(snapshot) }
|
|
141
|
+
nil
|
|
140
142
|
end
|
|
141
143
|
|
|
142
144
|
# Public: The method that will be used to synchronize local adapter with
|
|
@@ -247,19 +249,28 @@ module Flipper
|
|
|
247
249
|
return Flipper::Adapters::Poll.new(poller, local_adapter) unless @memory
|
|
248
250
|
|
|
249
251
|
Flipper::Adapters::Poll.new(poller, memory_adapter, synchronizer: -> {
|
|
250
|
-
sync_poll(poller.adapter)
|
|
252
|
+
sync_poll(poller.adapter, poller.synced_at)
|
|
251
253
|
})
|
|
252
254
|
end
|
|
253
255
|
|
|
254
256
|
# Every thread's Poll calls this after each poll. Threads don't wait on
|
|
255
257
|
# each other, so ones that read while a new version syncs sync it too.
|
|
256
|
-
|
|
258
|
+
# Once the version is synced, one thread per poll checks whether another
|
|
259
|
+
# process stored a different one, so the rest don't query the local
|
|
260
|
+
# adapter. A check that fails gives the poll back to the next thread.
|
|
261
|
+
def sync_poll(snapshot, polled_at)
|
|
257
262
|
version = snapshot.sync_version
|
|
258
|
-
|
|
263
|
+
claimed = false
|
|
264
|
+
if @memory.synced?(version)
|
|
265
|
+
claimed = @memory.claim_store_check(polled_at)
|
|
266
|
+
return unless claimed
|
|
267
|
+
return if @store.sync_version == version
|
|
268
|
+
end
|
|
259
269
|
|
|
260
270
|
@memory.sync(version) { sync_memory(snapshot) }
|
|
261
271
|
rescue StandardError
|
|
262
272
|
# Reads keep working from memory if the local adapter is down.
|
|
273
|
+
@memory.release_store_check(polled_at) if claimed
|
|
263
274
|
end
|
|
264
275
|
|
|
265
276
|
def http_adapter
|
|
@@ -12,7 +12,7 @@ module Flipper
|
|
|
12
12
|
|
|
13
13
|
def initialize(source = nil, threadsafe: true)
|
|
14
14
|
super
|
|
15
|
-
@syncing = 0
|
|
15
|
+
@syncing = Hash.new(0)
|
|
16
16
|
@overlaps = 0
|
|
17
17
|
@recopy = false
|
|
18
18
|
@changed_at = 0
|
|
@@ -50,23 +50,50 @@ module Flipper
|
|
|
50
50
|
!version.nil? && synchronize { @synced_version == version }
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
# Public: Returns true for the first thread to ask about the poll at
|
|
54
|
+
# polled_at, and false for the rest, so one thread per poll checks the
|
|
55
|
+
# local adapter's version. A thread still on an older poll gets false.
|
|
56
|
+
def claim_store_check(polled_at)
|
|
57
|
+
synchronize do
|
|
58
|
+
return false if @store_checked_at && polled_at <= @store_checked_at
|
|
59
|
+
@store_checked_at = polled_at
|
|
60
|
+
true
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Public: Gives back a claim whose check failed, so the next thread to
|
|
65
|
+
# read checks the poll at polled_at again.
|
|
66
|
+
def release_store_check(polled_at)
|
|
67
|
+
synchronize { @store_checked_at = nil if @store_checked_at == polled_at }
|
|
68
|
+
end
|
|
69
|
+
|
|
53
70
|
# Public: Runs the block that syncs version, then records it as synced.
|
|
54
|
-
# Records nothing if the block raises or
|
|
55
|
-
# time, because an older sync can write its flags after a newer
|
|
56
|
-
# next poll then syncs again and repairs them.
|
|
71
|
+
# Records nothing if the block raises or a sync of another version ran at
|
|
72
|
+
# the same time, because an older sync can write its flags after a newer
|
|
73
|
+
# one. The next poll then syncs again and repairs them. Threads syncing
|
|
74
|
+
# the same version write the same flags, so they can still record it,
|
|
75
|
+
# but one that raises may have left flags half written, so it forgets
|
|
76
|
+
# the recorded version and keeps syncs still running from recording.
|
|
57
77
|
def sync(version)
|
|
58
78
|
alone, overlaps = synchronize do
|
|
59
|
-
@syncing
|
|
60
|
-
@overlaps += 1 if
|
|
61
|
-
|
|
79
|
+
other_version = @syncing.any? { |syncing_version, _| syncing_version != version }
|
|
80
|
+
@overlaps += 1 if other_version
|
|
81
|
+
@syncing[version] += 1
|
|
82
|
+
[!other_version, @overlaps]
|
|
62
83
|
end
|
|
63
84
|
finished = false
|
|
64
85
|
yield
|
|
65
86
|
finished = true
|
|
66
87
|
ensure
|
|
67
88
|
synchronize do
|
|
68
|
-
@syncing -= 1
|
|
69
|
-
@
|
|
89
|
+
@syncing[version] -= 1
|
|
90
|
+
@syncing.delete(version) if @syncing[version] <= 0
|
|
91
|
+
if finished
|
|
92
|
+
@synced_version = version if alone && overlaps == @overlaps
|
|
93
|
+
else
|
|
94
|
+
@overlaps += 1
|
|
95
|
+
@synced_version = nil
|
|
96
|
+
end
|
|
70
97
|
end
|
|
71
98
|
end
|
|
72
99
|
|
data/lib/flipper/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flipper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.0.
|
|
4
|
+
version: 1.5.0.rc2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Nunemaker
|
|
@@ -194,7 +194,7 @@ metadata:
|
|
|
194
194
|
homepage_uri: https://www.flippercloud.io
|
|
195
195
|
source_code_uri: https://github.com/flippercloud/flipper
|
|
196
196
|
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
|
197
|
-
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.5.0.
|
|
197
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.5.0.rc2
|
|
198
198
|
funding_uri: https://github.com/sponsors/flippercloud
|
|
199
199
|
post_install_message:
|
|
200
200
|
rdoc_options: []
|