flipper 0.26.0.rc1 → 0.26.0.rc2

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
  SHA256:
3
- metadata.gz: 5b6c4a5c4ef29f126e9a08cc7fc7c70be9831b179dfc55486b88b8c5da5fdf44
4
- data.tar.gz: aab15578901fcab2b3717813aa37d3cc057554eea3d442f264f85707d94310f9
3
+ metadata.gz: 60ce7896afa06dd25ad8e6f8b4f419bbb992e16ce7147339af30ac15f338871d
4
+ data.tar.gz: 3a6635db6af529d29a2f1bd075fe45a82c77211bdd012d3613a89f2b98566975
5
5
  SHA512:
6
- metadata.gz: 79989c8d6149b13b6c960878d4ac701f98f5e3da9b44a567092a4ace82350ec8ccffcd7e9c9ea2619a2a2508b6a392e99c05b14ab14b59b5a0b3a58b4f211150
7
- data.tar.gz: 5192a0b9e1bebc39a28503861ba4eb35a05010a1841595e1282437c7d0694e3eccd02f215fbc6928b228948c6a02c8e9d26f85a5e23ae271fd0b32bc84bf6b53
6
+ metadata.gz: 6ce977a03bcafdfd4cb0427541eb0277b4dfbbadd723c86e12a7fcbec65d398663ed74fbdb9c46aa6b460e00e0025bd9853ed52c7a3cf3f44016e005d79e6eff
7
+ data.tar.gz: c422114b0e7076ebd7c0c63bef943a54aede502f253c5310a4e59f17daaadeafd435594aac7936c441adfc3a39fa3d5ba2ef17c589d828cefb5a977d750f0215
@@ -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
@@ -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,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.26.0.rc1'.freeze
2
+ VERSION = '0.26.0.rc2'.freeze
3
3
  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.26.0.rc1
4
+ version: 0.26.0.rc2
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-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby