Module: CI::Queue

Extended by:
Queue
Included in:
Queue
Defined in:
lib/ci/queue.rb,
lib/ci/queue/file.rb,
lib/ci/queue/grind.rb,
lib/ci/queue/redis.rb,
lib/ci/queue/bisect.rb,
lib/ci/queue/common.rb,
lib/ci/queue/static.rb,
lib/ci/queue/version.rb,
lib/ci/queue/redis/base.rb,
lib/ci/queue/redis/grind.rb,
lib/ci/queue/redis/retry.rb,
lib/ci/queue/build_record.rb,
lib/ci/queue/redis/worker.rb,
lib/ci/queue/configuration.rb,
lib/ci/queue/redis/monitor.rb,
lib/ci/queue/output_helpers.rb,
lib/ci/queue/circuit_breaker.rb,
lib/ci/queue/redis/supervisor.rb,
lib/ci/queue/redis/build_record.rb,
lib/ci/queue/redis/grind_record.rb,
lib/ci/queue/redis/grind_supervisor.rb,
lib/ci/queue/redis/test_time_record.rb

Defined Under Namespace

Modules: CircuitBreaker, Common, OutputHelpers, Redis, Warnings Classes: Bisect, BuildRecord, Configuration, File, Grind, Static

Constant Summary collapse

VERSION =
'0.56.0'
DEV_SCRIPTS_ROOT =
::File.expand_path('../../../../../redis', __FILE__)
RELEASE_SCRIPTS_ROOT =
::File.expand_path('../redis', __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#requeueableObject

Returns the value of attribute requeueable.



22
23
24
# File 'lib/ci/queue.rb', line 22

def requeueable
  @requeueable
end

#shufflerObject

Returns the value of attribute shuffler.



22
23
24
# File 'lib/ci/queue.rb', line 22

def shuffler
  @shuffler
end

Instance Method Details

#from_uri(url, config) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ci/queue.rb', line 49

def from_uri(url, config)
  uri = URI(url)
  implementation = case uri.scheme
  when 'list'
    Static
  when 'file', nil
    File
  when 'redis', 'rediss'
    require 'ci/queue/redis'
    Redis
  else
    raise ArgumentError, "Don't know how to handle #{uri.scheme} URLs"
  end
  implementation.from_uri(uri, config)
end

#requeueable?(test_result) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/ci/queue.rb', line 37

def requeueable?(test_result)
  requeueable.nil? || requeueable.call(test_result)
end

#shuffle(tests, random) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/ci/queue.rb', line 41

def shuffle(tests, random)
  if shuffler
    shuffler.call(tests, random)
  else
    tests.sort.shuffle(random: random)
  end
end

#time_nowObject



30
31
32
33
34
35
# File 'lib/ci/queue.rb', line 30

def time_now
  # Mocks like freeze_time should be cleaned when ci-queue runs, however,
  # we experienced cases when tests were enqueued with wrong timestamps, so we
  # safeguard Time.now here.
  GET_NOW.call
end