stoplight 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stoplight/data_store/memory.rb +16 -25
- data/lib/stoplight/version.rb +1 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63cf1781eee3560f3c9c349bf68c8775d7abc504
|
4
|
+
data.tar.gz: 87de1b959d4f19c8213578ffcf33bdbcacd65934
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add9f9034758b48d505b6b6ad3f2d4d776f26bf151a2fa15f81498f97aeed583094a3e86fa1a5d919d484bcc68f3dbd425a9098b4c3124816d7586821b554774
|
7
|
+
data.tar.gz: 05e604d3704db8185dd02f891806511bef83c62c4e51c15dbba8d2fcbafaf24e295ae5dcbc7b5b6651e89e73184f678b9d05f92c473a5ada774d6091c9f5d358
|
@@ -1,62 +1,53 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
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 =
|
11
|
-
@states =
|
12
|
-
|
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
|
-
|
18
|
+
synchronize { @failures.keys | @states.keys }
|
17
19
|
end
|
18
20
|
|
19
21
|
def get_all(light)
|
20
|
-
[
|
22
|
+
synchronize { [@failures[light.name], @states[light.name]] }
|
21
23
|
end
|
22
24
|
|
23
25
|
def get_failures(light)
|
24
|
-
|
26
|
+
synchronize { @failures[light.name] }
|
25
27
|
end
|
26
28
|
|
27
29
|
def record_failure(light, failure)
|
28
|
-
|
30
|
+
synchronize do
|
29
31
|
n = light.threshold - 1
|
30
|
-
failures =
|
31
|
-
|
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
|
-
|
38
|
+
synchronize { @failures.delete(light.name) }
|
38
39
|
end
|
39
40
|
|
40
41
|
def get_state(light)
|
41
|
-
|
42
|
+
synchronize { @states[light.name] }
|
42
43
|
end
|
43
44
|
|
44
45
|
def set_state(light, state)
|
45
|
-
|
46
|
+
synchronize { @states[light.name] = state }
|
46
47
|
end
|
47
48
|
|
48
49
|
def clear_state(light)
|
49
|
-
|
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
|
data/lib/stoplight/version.rb
CHANGED
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.
|
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
|