flipper 0.26.0.rc1 → 0.26.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
  SHA256:
3
- metadata.gz: 5b6c4a5c4ef29f126e9a08cc7fc7c70be9831b179dfc55486b88b8c5da5fdf44
4
- data.tar.gz: aab15578901fcab2b3717813aa37d3cc057554eea3d442f264f85707d94310f9
3
+ metadata.gz: e5edb0409042f8d4d5905b8d526fd1d240a75dbee2d947b8ae4adae0c534af5f
4
+ data.tar.gz: 6bc01d5f7c0ee5f3d64d30faaa599b155d6220e249006d2ead7168bc47938202
5
5
  SHA512:
6
- metadata.gz: 79989c8d6149b13b6c960878d4ac701f98f5e3da9b44a567092a4ace82350ec8ccffcd7e9c9ea2619a2a2508b6a392e99c05b14ab14b59b5a0b3a58b4f211150
7
- data.tar.gz: 5192a0b9e1bebc39a28503861ba4eb35a05010a1841595e1282437c7d0694e3eccd02f215fbc6928b228948c6a02c8e9d26f85a5e23ae271fd0b32bc84bf6b53
6
+ metadata.gz: 60fee2e4a0d97a26b7403736b4422c0e69a0e9e452469e3f29e7af684001c38f2c957acdfa3f8f0554315d021a7e7091bb40898247e45d4658b14b31bc1de22f
7
+ data.tar.gz: bf45e695be511513be967bffd75c4e48d3af0f05b05264ee3b13a9df8bba8af929ccbf6b7a1f05c6c3a7d5476ceb757e3dda852f8e42b745bf7171f42538fb14
data/Changelog.md CHANGED
@@ -2,9 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## 0.26.0.rc1
5
+ ## 0.26.0
6
6
 
7
7
  * Cloud Background Polling (https://github.com/jnunemaker/flipper/pull/682)
8
+ * Changed default branch from master to main
9
+ * Allow configuring railtie via ENV vars (https://github.com/jnunemaker/flipper/pull/681)
10
+ * flipper-ui: Fix issue preventing feature flags being enabled when confirm_fully_enable is on and feature_removal_enabled is off (https://github.com/jnunemaker/flipper/pull/680)
8
11
 
9
12
  ## 0.25.4
10
13
 
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ end
18
18
  desc 'Tags version, pushes to remote, and pushes gem'
19
19
  task release: :build do
20
20
  sh 'git', 'tag', "v#{Flipper::VERSION}"
21
- sh 'git push origin master'
21
+ sh 'git push origin main'
22
22
  sh "git push origin v#{Flipper::VERSION}"
23
23
  puts "\nWhat OTP code should be used?"
24
24
  otp_code = STDIN.gets.chomp
@@ -7,9 +7,7 @@ module Flipper
7
7
  module Adapters
8
8
  class Poll
9
9
  class Poller
10
- PREFIX = "[flipper http async poll adapter]".freeze
11
-
12
- attr_reader :thread, :pid, :mutex, :logger, :interval, :last_synced_at
10
+ attr_reader :thread, :pid, :mutex, :interval, :last_synced_at
13
11
 
14
12
  def self.instances
15
13
  @instances ||= Concurrent::Map.new
@@ -21,7 +19,7 @@ module Flipper
21
19
  end
22
20
 
23
21
  def self.reset
24
- instances.clear
22
+ instances.each {|_,poller| poller.stop }.clear
25
23
  end
26
24
 
27
25
  def initialize(options = {})
@@ -29,14 +27,14 @@ module Flipper
29
27
  @pid = Process.pid
30
28
  @mutex = Mutex.new
31
29
  @adapter = Memory.new
30
+ @instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
32
31
  @remote_adapter = options.fetch(:remote_adapter)
33
- @logger = options.fetch(:logger) { Logger.new(STDOUT) }
34
32
  @interval = options.fetch(:interval, 10).to_f
35
33
  @lock = Concurrent::ReadWriteLock.new
36
34
  @last_synced_at = Concurrent::AtomicFixnum.new(0)
37
35
 
38
36
  if @interval < 1
39
- warn "#{PREFIX} interval must be greater than or equal to 1 but was #{@interval}. Setting @interval to 1."
37
+ warn "Flipper::Cloud poll interval must be greater than or equal to 1 but was #{@interval}. Setting @interval to 1."
40
38
  @interval = 1
41
39
  end
42
40
 
@@ -57,7 +55,9 @@ module Flipper
57
55
  end
58
56
 
59
57
  def stop
60
- logger.debug { "#{PREFIX} Stopping worker" }
58
+ @instrumenter.instrument("poller.#{InstrumentationNamespace}", {
59
+ operation: :stop,
60
+ })
61
61
  @thread&.kill
62
62
  end
63
63
 
@@ -66,15 +66,15 @@ module Flipper
66
66
  sleep jitter
67
67
  start = Concurrent.monotonic_time
68
68
  begin
69
- logger.debug { "#{PREFIX} Making a checkity checkity" }
70
-
71
- adapter = Memory.new
72
- adapter.import(@remote_adapter)
69
+ @instrumenter.instrument("poller.#{InstrumentationNamespace}", operation: :poll) do
70
+ adapter = Memory.new
71
+ adapter.import(@remote_adapter)
73
72
 
74
- @lock.with_write_lock { @adapter.import(adapter) }
75
- @last_synced_at.update { |time| Concurrent.monotonic_time }
73
+ @lock.with_write_lock { @adapter.import(adapter) }
74
+ @last_synced_at.update { |time| Concurrent.monotonic_time }
75
+ end
76
76
  rescue => exception
77
- logger.debug { "#{PREFIX} Exception: #{exception.inspect}" }
77
+ # you can instrument these using poller.flipper
78
78
  end
79
79
 
80
80
  sleep_interval = interval - (Concurrent.monotonic_time - start)
@@ -103,7 +103,9 @@ module Flipper
103
103
  begin
104
104
  return if thread_alive?
105
105
  @thread = Thread.new { run }
106
- logger.debug { "#{PREFIX} Worker thread [#{@thread.object_id}] started" }
106
+ @instrumenter.instrument("poller.#{InstrumentationNamespace}", {
107
+ operation: :thread_start,
108
+ })
107
109
  ensure
108
110
  mutex.unlock
109
111
  end
@@ -1,5 +1,5 @@
1
1
  module Flipper
2
2
  METADATA = {
3
- 'changelog_uri' => 'https://github.com/jnunemaker/flipper/blob/master/Changelog.md',
3
+ 'changelog_uri' => 'https://github.com/jnunemaker/flipper/blob/main/Changelog.md',
4
4
  }.freeze
5
5
  end
@@ -2,11 +2,11 @@ module Flipper
2
2
  class Railtie < Rails::Railtie
3
3
  config.before_configuration do
4
4
  config.flipper = ActiveSupport::OrderedOptions.new.update(
5
- env_key: "flipper",
6
- memoize: true,
7
- preload: true,
8
- instrumenter: ActiveSupport::Notifications,
9
- log: true
5
+ env_key: ENV.fetch('FLIPPER_ENV_KEY', 'flipper'),
6
+ memoize: ENV.fetch('FLIPPER_MEMOIZE', 'true').casecmp('true').zero?,
7
+ preload: ENV.fetch('FLIPPER_PRELOAD', 'true').casecmp('true').zero?,
8
+ instrumenter: ENV.fetch('FLIPPER_INSTRUMENTER', 'ActiveSupport::Notifications').constantize,
9
+ log: ENV.fetch('FLIPPER_LOG', 'true').casecmp('true').zero?
10
10
  )
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.26.0.rc1'.freeze
2
+ VERSION = '0.26.0'.freeze
3
3
  end
@@ -18,6 +18,42 @@ RSpec.describe Flipper::Railtie do
18
18
  subject { application.initialize! }
19
19
 
20
20
  describe 'initializers' do
21
+ it 'can set env_key from ENV' do
22
+ ENV['FLIPPER_ENV_KEY'] = 'flopper'
23
+
24
+ subject
25
+ expect(config.env_key).to eq('flopper')
26
+ end
27
+
28
+ it 'can set memoize from ENV' do
29
+ ENV['FLIPPER_MEMOIZE'] = 'false'
30
+
31
+ subject
32
+ expect(config.memoize).to eq(false)
33
+ end
34
+
35
+ it 'can set preload from ENV' do
36
+ ENV['FLIPPER_PRELOAD'] = 'false'
37
+
38
+ subject
39
+ expect(config.preload).to eq(false)
40
+ end
41
+
42
+ it 'can set instrumenter from ENV' do
43
+ stub_const('My::Cool::Instrumenter', Class.new)
44
+ ENV['FLIPPER_INSTRUMENTER'] = 'My::Cool::Instrumenter'
45
+
46
+ subject
47
+ expect(config.instrumenter).to eq(My::Cool::Instrumenter)
48
+ end
49
+
50
+ it 'can set log from ENV' do
51
+ ENV['FLIPPER_LOG'] = 'false'
52
+
53
+ subject
54
+ expect(config.log).to eq(false)
55
+ end
56
+
21
57
  it 'sets defaults' do
22
58
  subject # initialize
23
59
  expect(config.env_key).to eq("flipper")
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.26.0.rc1
4
+ version: 0.26.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: 2022-11-11 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -183,7 +183,7 @@ homepage: https://github.com/jnunemaker/flipper
183
183
  licenses:
184
184
  - MIT
185
185
  metadata:
186
- changelog_uri: https://github.com/jnunemaker/flipper/blob/master/Changelog.md
186
+ changelog_uri: https://github.com/jnunemaker/flipper/blob/main/Changelog.md
187
187
  post_install_message:
188
188
  rdoc_options: []
189
189
  require_paths:
@@ -195,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">"
198
+ - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: 1.3.1
200
+ version: '0'
201
201
  requirements: []
202
202
  rubygems_version: 3.3.7
203
203
  signing_key: