event_tracer 0.6.0 → 0.6.1

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: e27db9c289f5e94f2f3370fccb3c219222ccb538c21ffc022d67d83a3a42b1c6
4
- data.tar.gz: efae6fe651ef5833b44a8ec420d72df76f2ca234e639348b3d756c92343640b5
3
+ metadata.gz: bc787e6f2e531d8525792eec4d55f3576f7b6543e356319fce7c065c436385d6
4
+ data.tar.gz: 22172cf85886ee0b668820d55bd13346997cd648b542337cc982c91510f01f50
5
5
  SHA512:
6
- metadata.gz: 1071f39a1ee582dad14d580bf3086330d83fefaf3942d48abb8d01402b13888a9f83867cb0795c6ed57a150c793d0acf76c0245cfef7cdfda2e330e7afb8674e
7
- data.tar.gz: 6abbecd3c7e32610c66b336f1d2e304376a42e73789538f4ea93b18bad96f67f6b4949363fb0831d19ad6bfa6dfa69de2269fca6ce27cfe7652808792b6fcef3
6
+ metadata.gz: d2afa747344e9e07aa85fa1d22a6612fca83df74e2bcfeb384b4f91e742e2d4a545c1070ceb9006592dff7bc97fefefe40ed4f326002f7f76119be24e9e26287
7
+ data.tar.gz: c176243abadde0675d267138476b2dbe9cbe20f78a3d49a479c96e9a086abb83ff4df859da65029aadb115d7d42a83fddf630de32ed797e7f7c8d930dec05fcf
@@ -58,8 +58,15 @@ module EventTracer
58
58
  attr_reader :buffer_size, :flush_interval, :buffer
59
59
 
60
60
  def add_item?
61
- buffer.size < buffer_size &&
62
- (buffer.empty? || buffer.first[:created_at] > Time.now - flush_interval)
61
+ return false if buffer.size >= buffer_size
62
+
63
+ # NOTE: we cannot use buffer.empty? then buffer.first here
64
+ # due to race-condition when another thread flushes the buffer
65
+ # right after buffer.empty? but before buffer.first is called.
66
+ # If we have more complicated use case, we may need to start introducing
67
+ # mutext.
68
+ first_item = buffer.first
69
+ first_item.nil? || first_item[:created_at] > Time.now - flush_interval
63
70
  end
64
71
  end
65
72
  end
@@ -1,3 +1,3 @@
1
1
  module EventTracer
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - melvrickgoh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-27 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby