Interface Exporter


public interface Exporter
Minimal interface to be implemented by concrete exporters.

A concrete implementation should always provide a default, no-arguments constructor. It is not recommended to do anything in the constructor, but rather use the provided callbacks for configuration, setup, resource allocation, etc.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Hook to perform any tear down.
    default void
    configure(Context context)
    Use the provided configuration at this point to configure your exporter.
    void
    export(Record<?> record)
    Called at least once for every record to be exported.
    default void
    open(Controller controller)
    Hook to perform any setup for a given exporter.
  • Method Details

    • configure

      default void configure(Context context) throws Exception
      Use the provided configuration at this point to configure your exporter.

      This method is called in two difference contexts: 1. right before opening the exporter, to configure the exporter 2. at startup, to allow validation of the exporter configuration.

      To fail-fast at startup time (e.g. database endpoint is missing), for now you must throw an exception.

      Note that the instance configured at startup will be discarded immediately.

      Parameters:
      context - the exporter context
      Throws:
      Exception
    • open

      default void open(Controller controller)
      Hook to perform any setup for a given exporter. This method is the first method called during the lifecycle of an exporter, and should be use to create, allocate or configure resources. After this is called, records will be published to this exporter.
      Parameters:
      controller - specific controller for this exporter
    • close

      default void close()
      Hook to perform any tear down. This is method is called exactly once at the end of the lifecycle of an exporter, and should be used to close and free any remaining resources.
    • export

      void export(Record<?> record)
      Called at least once for every record to be exported. Once a record is guaranteed to have been exported, implementations should call Controller.updateLastExportedRecordPosition(long) to signal that this record should not be received here ever again.

      Should the export method throw an unexpected RuntimeException, the method will be called indefinitely until it terminates without any exception. It is up to the implementation to handle errors properly, to implement retry strategies, etc.

      Given Record just wraps the underlying internal buffer. This means if the implementation needs to collect multiple records it either has to call JsonSerializable.toJson() to get the serialized version of the record or Record.clone() to get a deep copy.

      Parameters:
      record - the record to export