Module: EachShardWorker

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Utils::StrongMemoize
Included in:
RepositoryCheck::DispatchWorker
Defined in:
app/workers/concerns/each_shard_worker.rb

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#each_eligible_shardObject


7
8
9
10
11
12
13
# File 'app/workers/concerns/each_shard_worker.rb', line 7

def each_eligible_shard
  Gitlab::ShardHealthCache.update(eligible_shard_names)

  eligible_shard_names.each do |shard_name|
    yield shard_name
  end
end

#eligible_shard_namesObject

override when you want to filter out some shards


16
17
18
# File 'app/workers/concerns/each_shard_worker.rb', line 16

def eligible_shard_names
  healthy_shard_names
end

#healthy_ready_shardsObject


26
27
28
# File 'app/workers/concerns/each_shard_worker.rb', line 26

def healthy_ready_shards
  ready_shards.select(&:success)
end

#healthy_shard_namesObject


20
21
22
23
24
# File 'app/workers/concerns/each_shard_worker.rb', line 20

def healthy_shard_names
  strong_memoize(:healthy_shard_names) do
    healthy_ready_shards.map { |result| result.labels[:shard] }
  end
end

#ready_shardsObject


30
31
32
# File 'app/workers/concerns/each_shard_worker.rb', line 30

def ready_shards
  Gitlab::HealthChecks::GitalyCheck.readiness
end