Class: TranslationDiff::Dispatcher
- Inherits:
-
Object
- Object
- TranslationDiff::Dispatcher
- Includes:
- Instrumentation
- Defined in:
- lib/translation_diff/dispatcher.rb
Overview
Sends batches to the provider, throttles each one, and reports what it cost -- the seam between cache and wire.
Constant Summary
Constants included from Instrumentation
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #dispatch(segments) ⇒ Object
-
#initialize(provider:, from:, to:, call_id:, options: {}, config: nil) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
Constructor Details
#initialize(provider:, from:, to:, call_id:, options: {}, config: nil) ⇒ Dispatcher
Returns a new instance of Dispatcher.
7 8 9 10 11 12 13 14 |
# File 'lib/translation_diff/dispatcher.rb', line 7 def initialize(provider:, from:, to:, call_id:, options: {}, config: nil) @provider = provider @from = from @to = to @call_id = call_id @options = @config = config || TranslationDiff.config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/translation_diff/dispatcher.rb', line 5 def config @config end |
Instance Method Details
#dispatch(segments) ⇒ Object
16 17 18 19 |
# File 'lib/translation_diff/dispatcher.rb', line 16 def dispatch(segments) batches = TranslationDiff::Batch.pack(segments, capabilities: @provider.class.capabilities) batches.each { |batch| send_batch(batch) } end |