Class: Julewire::Ractor::Fanout
- Inherits:
-
Object
- Object
- Julewire::Ractor::Fanout
- Defined in:
- lib/julewire/ractor/fanout.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #after_fork! ⇒ Object
- #close(timeout: nil) ⇒ Object
- #emit(record) ⇒ Object
- #flush(timeout: nil) ⇒ Object
- #health ⇒ Object
-
#initialize(destinations:, name: :ractor_fanout, on_failure: nil) ⇒ Fanout
constructor
A new instance of Fanout.
- #resource_identity ⇒ Object
Constructor Details
#initialize(destinations:, name: :ractor_fanout, on_failure: nil) ⇒ Fanout
Returns a new instance of Fanout.
8 9 10 11 12 13 14 15 16 |
# File 'lib/julewire/ractor/fanout.rb', line 8 def initialize(destinations:, name: :ractor_fanout, on_failure: nil) @name = Core::Destinations.normalize_name(name) @destinations = Array(destinations).map { normalize_destination(it) }.freeze raise ArgumentError, "destinations must not be empty" if @destinations.empty? Core::Validation.validate_callable!(on_failure, name: :on_failure, allow_nil: true) @on_failure = on_failure @health = Core::Integration::DestinationHealth.new(counter_keys: [], failure_counter: nil) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/julewire/ractor/fanout.rb', line 6 def name @name end |
Instance Method Details
#after_fork! ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/julewire/ractor/fanout.rb', line 31 def after_fork! @destinations.each do |destination| destination.after_fork! if destination.respond_to?(:after_fork!) rescue StandardError => e record_failure(e, action: :after_fork, destination: destination.name) end self end |
#close(timeout: nil) ⇒ Object
27 28 29 |
# File 'lib/julewire/ractor/fanout.rb', line 27 def close(timeout: nil) call_lifecycle(:close, timeout: timeout) end |
#emit(record) ⇒ Object
18 19 20 21 |
# File 'lib/julewire/ractor/fanout.rb', line 18 def emit(record) @destinations.each { emit_to_destination(it, record) } nil end |
#flush(timeout: nil) ⇒ Object
23 24 25 |
# File 'lib/julewire/ractor/fanout.rb', line 23 def flush(timeout: nil) call_lifecycle(:flush, timeout: timeout) end |
#health ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/julewire/ractor/fanout.rb', line 42 def health destinations = @destinations.to_h { [it.name, destination_health(it)] } @health.snapshot( destinations: destinations, status: health_status(destinations) ) end |
#resource_identity ⇒ Object
40 |
# File 'lib/julewire/ractor/fanout.rb', line 40 def resource_identity = self |