stoplight 2.1.1 → 2.1.2

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: b437a495ce48094d005d041a4cb8b9650f00980a
4
- data.tar.gz: d800f7a86abc22e555a268e196724f57cf9324f0
3
+ metadata.gz: 63cf1781eee3560f3c9c349bf68c8775d7abc504
4
+ data.tar.gz: 87de1b959d4f19c8213578ffcf33bdbcacd65934
5
5
  SHA512:
6
- metadata.gz: 016ae8d5369b6014df8e912f1268d179721ac29c0cc924c9568266c5f4b38ee052b622550dbe7bed46688f17af44b305a1dfc165889a02eec45ed533c34a435b
7
- data.tar.gz: c413ef054fa34bbad236c5c734e55103e4a519b893b13c7b67e29ae9ca95cd8e7b850ed2f4019cda21f53e83e82d4417b048fe6108edd23fddc9e2a603420c59
6
+ metadata.gz: add9f9034758b48d505b6b6ad3f2d4d776f26bf151a2fa15f81498f97aeed583094a3e86fa1a5d919d484bcc68f3dbd425a9098b4c3124816d7586821b554774
7
+ data.tar.gz: 05e604d3704db8185dd02f891806511bef83c62c4e51c15dbba8d2fcbafaf24e295ae5dcbc7b5b6651e89e73184f678b9d05f92c473a5ada774d6091c9f5d358
@@ -1,62 +1,53 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'concurrent'
3
+ require 'monitor'
4
4
 
5
5
  module Stoplight
6
6
  module DataStore
7
7
  # @see Base
8
8
  class Memory < Base
9
+ include MonitorMixin
10
+
9
11
  def initialize
10
- @failures = Concurrent::Map.new { [] }
11
- @states = Concurrent::Map.new { State::UNLOCKED }
12
- @lock = Monitor.new
12
+ @failures = Hash.new { |h, k| h[k] = [] }
13
+ @states = Hash.new { |h, k| h[k] = State::UNLOCKED }
14
+ super() # MonitorMixin
13
15
  end
14
16
 
15
17
  def names
16
- (all_failures.keys + all_states.keys).uniq
18
+ synchronize { @failures.keys | @states.keys }
17
19
  end
18
20
 
19
21
  def get_all(light)
20
- [get_failures(light), get_state(light)]
22
+ synchronize { [@failures[light.name], @states[light.name]] }
21
23
  end
22
24
 
23
25
  def get_failures(light)
24
- all_failures[light.name]
26
+ synchronize { @failures[light.name] }
25
27
  end
26
28
 
27
29
  def record_failure(light, failure)
28
- @lock.synchronize do
30
+ synchronize do
29
31
  n = light.threshold - 1
30
- failures = get_failures(light).first(n).unshift(failure)
31
- all_failures[light.name] = failures
32
- failures.size
32
+ @failures[light.name] = @failures[light.name].first(n)
33
+ @failures[light.name].unshift(failure).size
33
34
  end
34
35
  end
35
36
 
36
37
  def clear_failures(light)
37
- all_failures.delete(light.name)
38
+ synchronize { @failures.delete(light.name) }
38
39
  end
39
40
 
40
41
  def get_state(light)
41
- all_states[light.name]
42
+ synchronize { @states[light.name] }
42
43
  end
43
44
 
44
45
  def set_state(light, state)
45
- all_states[light.name] = state
46
+ synchronize { @states[light.name] = state }
46
47
  end
47
48
 
48
49
  def clear_state(light)
49
- all_states.delete(light.name)
50
- end
51
-
52
- private
53
-
54
- def all_failures
55
- @failures
56
- end
57
-
58
- def all_states
59
- @states
50
+ synchronize { @states.delete(light.name) }
60
51
  end
61
52
  end
62
53
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Stoplight
4
- VERSION = Gem::Version.new('2.1.1')
4
+ VERSION = Gem::Version.new('2.1.2')
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stoplight
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cameron Desautels
@@ -12,20 +12,6 @@ bindir: bin
12
12
  cert_chain: []
13
13
  date: 2018-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: concurrent-ruby
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: '1.0'
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: benchmark-ips
31
17
  requirement: !ruby/object:Gem::Requirement