Class PulsarFunctionAdministration

java.lang.Object
org.springframework.pulsar.function.PulsarFunctionAdministration
All Implemented Interfaces:
Lifecycle, Phased, SmartLifecycle

public class PulsarFunctionAdministration extends Object implements SmartLifecycle
Responsible for creating and updating any user-defined Pulsar functions, sinks, or sources.
Author:
Chris Bono
  • Constructor Details

    • PulsarFunctionAdministration

      public PulsarFunctionAdministration(PulsarAdministration pulsarAdministration, ObjectProvider<PulsarFunction> pulsarFunctions, ObjectProvider<PulsarSink> pulsarSinks, ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures)
      Construct a PulsarFunctionAdministration instance.
      Parameters:
      pulsarAdministration - the pulsar admin to make the API calls with
      pulsarFunctions - provider of functions to create/update
      pulsarSinks - provider of sinks to create/update
      pulsarSources - provider of sources to create/update
      failFast - whether to stop processing when a failure occurs
      propagateFailures - whether to throw an exception when a failure occurs during server startup while creating/updating functions
      propagateStopFailures - whether to throw an exception when a failure occurs during server shutdown while enforcing stop policy on functions
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • createOrUpdateUserDefinedFunctions

      public void createOrUpdateUserDefinedFunctions()
      Called during server startup, creates or updates any Pulsar functions registered by the application.

      The functions, sinks, and sources are processed serially (in that order) as follows:

      • A create or update operation is performed depending on whether or not the function already exists.
      • If the operation fails the failFast property controls whether processing should stop (fail fast) or continue on w/ the next function.

      Once processing is complete, any failures are either logged or thrown to the caller (propagated) dependent on the propagateFailures property.

      Throws:
      PulsarFunctionAdministration.PulsarFunctionException - containing processing errors if the propagateFailures property is set to true
    • enforceStopPolicyOnUserDefinedFunctions

      public void enforceStopPolicyOnUserDefinedFunctions()
      Called during server shutdown, enforces the stop policy on all Pulsar functions that were successfully processed during server startup.

      The functions, sinks, and sources are processed in reverse startup order as follows:

      • The stop policy of each function is used to determine if the function should be stopped, removed, or left alone.

      Once processing is complete, any failures are either logged or thrown to the caller (propagated) dependent on the propagateStopFailures property.

      Throws:
      PulsarFunctionAdministration.PulsarFunctionException - containing processing errors if the propagateStopFailures property is set to true