Class AiidaStreamer

java.lang.Object
energy.eddie.aiida.streamers.AiidaStreamer
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
MqttStreamer

public abstract class AiidaStreamer extends Object implements AutoCloseable
  • Field Details

    • commandSink

      protected final reactor.core.publisher.Sinks.Many<PermissionCommand> commandSink
    • schemaFormatterRegistry

      protected final SchemaFormatterRegistry schemaFormatterRegistry
    • recordFlux

      protected reactor.core.publisher.Flux<AiidaRecord> recordFlux
  • Constructor Details

    • AiidaStreamer

      protected AiidaStreamer(reactor.core.publisher.Flux<AiidaRecord> recordFlux, SchemaFormatterRegistry schemaFormatterRegistry, reactor.core.publisher.Sinks.Many<PermissionCommand> commandSink)
      Create a new AiidaStreamer and sets the Flux for records and status messages that should be sent. The constructor should initialize and prepare any necessary resources but only after connect() was called, connections should be opened and data streamed.
      Parameters:
      recordFlux - Flux, where records that should be sent are available.
      commandSink - Sink, to which a PermissionCommand is published when the EP sends a control command.
  • Method Details

    • connect

      public abstract void connect()
      Open required connections to the streaming target (EP) in this method, not beforehand. Subscribe to the Fluxes in this method, to receive records and status messages that shall be sent. Start listening for termination requests from the EP.
    • close

      public abstract void close()
      Unsubscribe from any Flux and free any used resources in this method. May flush all queued messages beforehand.
      Specified by:
      close in interface AutoCloseable
    • closeTerminally

      public abstract void closeTerminally(AiidaConnectionStatusMessageDto statusMessage)
      Sends a AiidaConnectionStatusMessageDto with the passed status before closing this streamer for good. May block until the passed statusMessage is transmitted.
      See Also:
    • setTransmissionEnabled

      public abstract void setTransmissionEnabled(boolean enabled)
      Enables or disables data transmission for this streamer. While disabled, records are not published to the EP.
    • updateRecordFlux

      public abstract void updateRecordFlux(reactor.core.publisher.Flux<AiidaRecord> recordFlux)
      Replaces the record flux this streamer is subscribed to and resubscribes. Used to apply a new transmission schedule, which re-aggregates the upstream records on a different cadence.