Class: DispatchPolicy::Gates::GlobalCap
Instance Attribute Summary
#name, #partition_by, #policy
Instance Method Summary
collapse
#initialize, #partition_key_for, register, registry
Instance Method Details
6
7
8
|
# File 'lib/dispatch_policy/gates/global_cap.rb', line 6
def configure(max:)
@max = max
end
|
#filter(batch, context) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/dispatch_policy/gates/global_cap.rb', line 14
def filter(batch, context)
limit = resolve(@max, nil).to_i
in_flight = PartitionInflightCount.total_for(policy_name: policy.name, gate_name: name)
capacity = [ limit - in_flight, 0 ].max
head = batch.first(capacity)
context.record_partitions(head.map { |s| [ s, "default" ] }, gate: name)
head
end
|
#tracks_inflight? ⇒ Boolean
10
11
12
|
# File 'lib/dispatch_policy/gates/global_cap.rb', line 10
def tracks_inflight?
true
end
|