Class: CI::Queue::Static
- Inherits:
-
Object
show all
- Includes:
- Common
- Defined in:
- lib/ci/queue/static.rb
Constant Summary
collapse
- TEN_MINUTES =
60 * 10
Constants included
from Common
Common::CONNECTION_ERRORS
Instance Attribute Summary collapse
Attributes included from Common
#config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Common
#flaky?, #release!, #report_failure!, #report_success!, #rescue_connection_errors, #retrying?
Constructor Details
#initialize(tests, config) ⇒ Static
Returns a new instance of Static.
18
19
20
21
22
23
|
# File 'lib/ci/queue/static.rb', line 18
def initialize(tests, config)
@queue = tests
@config = config
@progress = 0
@total = tests.size
end
|
Instance Attribute Details
#progress ⇒ Object
Returns the value of attribute progress.
16
17
18
|
# File 'lib/ci/queue/static.rb', line 16
def progress
@progress
end
|
#total ⇒ Object
Returns the value of attribute total.
16
17
18
|
# File 'lib/ci/queue/static.rb', line 16
def total
@total
end
|
Class Method Details
.from_uri(uri, config) ⇒ Object
8
9
10
11
|
# File 'lib/ci/queue/static.rb', line 8
def from_uri(uri, config)
tests = uri.opaque.split(':').map { |t| CGI.unescape(t) }
new(tests, config)
end
|
Instance Method Details
#acknowledge(test) ⇒ Object
76
77
78
79
|
# File 'lib/ci/queue/static.rb', line 76
def acknowledge(test)
@progress += 1
true
end
|
#build ⇒ Object
29
30
31
|
# File 'lib/ci/queue/static.rb', line 29
def build
@build ||= BuildRecord.new(self)
end
|
#created_at=(timestamp) ⇒ Object
46
47
48
|
# File 'lib/ci/queue/static.rb', line 46
def created_at=(timestamp)
@created_at ||= timestamp
end
|
#distributed? ⇒ Boolean
25
26
27
|
# File 'lib/ci/queue/static.rb', line 25
def distributed?
false
end
|
#exhausted? ⇒ Boolean
72
73
74
|
# File 'lib/ci/queue/static.rb', line 72
def exhausted?
@queue.empty?
end
|
#expired? ⇒ Boolean
50
51
52
|
# File 'lib/ci/queue/static.rb', line 50
def expired?
(@created_at.to_f TEN_MINUTES) < Time.now.to_f
end
|
#increment_test_failed ⇒ Object
81
82
83
|
# File 'lib/ci/queue/static.rb', line 81
def increment_test_failed
@test_failed = test_failed + 1
end
|
#max_test_failed? ⇒ Boolean
89
90
91
92
93
|
# File 'lib/ci/queue/static.rb', line 89
def max_test_failed?
return false if config.max_test_failed.nil?
test_failed >= config.max_test_failed
end
|
#poll ⇒ Object
66
67
68
69
70
|
# File 'lib/ci/queue/static.rb', line 66
def poll
while config.circuit_breakers.none?(&:open?) && !max_test_failed? && test = @queue.shift
yield index.fetch(test)
end
end
|
#populate(tests, random: nil) ⇒ Object
41
42
43
44
|
# File 'lib/ci/queue/static.rb', line 41
def populate(tests, random: nil)
@index = tests.map { |t| [t.id, t] }.to_h
self
end
|
#populated? ⇒ Boolean
54
55
56
|
# File 'lib/ci/queue/static.rb', line 54
def populated?
!!defined?(@index)
end
|
#requeue(test) ⇒ Object
95
96
97
98
99
100
101
102
|
# File 'lib/ci/queue/static.rb', line 95
def requeue(test)
test_key = test.id
return false unless should_requeue?(test_key)
requeues[test_key] += 1
@queue.unshift(test_key)
true
end
|
#retry_queue ⇒ Object
37
38
39
|
# File 'lib/ci/queue/static.rb', line 37
def retry_queue
self
end
|
#size ⇒ Object
62
63
64
|
# File 'lib/ci/queue/static.rb', line 62
def size
@queue.size
end
|
#supervisor ⇒ Object
33
34
35
|
# File 'lib/ci/queue/static.rb', line 33
def supervisor
raise NotImplementedError, "This type of queue can't be supervised"
end
|
#test_failed ⇒ Object
85
86
87
|
# File 'lib/ci/queue/static.rb', line 85
def test_failed
@test_failed ||= 0
end
|
#to_a ⇒ Object
58
59
60
|
# File 'lib/ci/queue/static.rb', line 58
def to_a
@queue.map { |i| index.fetch(i) }
end
|