Interface QueryUpdateEmitter

All Superinterfaces:
DescribableComponent
All Known Implementing Classes:
SimpleQueryUpdateEmitter

public interface QueryUpdateEmitter extends DescribableComponent
Query-specific component that interacts with subscription queries about update, errors, and when there are no more update.

Implementations of the QueryUpdateEmitter are expected to be context-aware, to ensure operations occur within the correct order of (for example) the lifecycle of an event handling function.

Since:
3.3.0
Author:
Milan Savic, Steven van Beelen
  • Field Details

  • Method Details

    • forContext

      static QueryUpdateEmitter forContext(ProcessingContext context)
      Creates a query update emitter for the given ProcessingContext.

      You can use this emitter only for the context it was created for. There is no harm in using this method more than once with the same context, as the same emitter will be returned.

      Parameters:
      context - The ProcessingContext to create the emitter for.
      Returns:
      The emitter specific for the given context.
    • emit

      default <Q> void emit(Class<Q> queryType, Predicate<? super Q> filter, @Nullable Object update)
      Emits given update to subscription queries matching the given queryType and given filter.
      Type Parameters:
      Q - The type of the QueryMessage to filter on.
      Parameters:
      queryType - The type of the QueryMessage to filter on.
      filter - A predicate to filter matching subscription queries based on the Message.payload() converted to the given queryType.
      update - The incremental update to emit for subscription queries matching the given filter.
      Throws:
      MessageTypeNotResolvedException - If the given queryType has no known MessageType equivalent required to filter the Message.payload().
      ConversionException - If the Message.payload() could not be converted to the given queryType to perform the given filter. Will only occur if a MessageType could be found for the given queryType.
    • emit

      <Q> void emit(Class<Q> queryType, Predicate<? super Q> filter, Supplier<Object> updateSupplier)
      Emits the outcome of the updateSupplier to subscription queries matching the given queryType and given filter.

      The updateSupplier is only invoked whenever there are matching queries.

      Type Parameters:
      Q - The type of the QueryMessage to filter on.
      Parameters:
      queryType - The type of the QueryMessage to filter on.
      filter - A predicate to filter matching subscription queries based on the Message.payload() converted to the given queryType
      updateSupplier - The update supplier to emit for subscription queries matching the given queryType and filter.
      Throws:
      MessageTypeNotResolvedException - If the given queryType has no known MessageType equivalent required to filter the Message.payload().
      ConversionException - If the Message.payload() could not be converted to the given queryType to perform the given filter. Will only occur if a MessageType could be found for the given queryType.
    • emit

      default void emit(QualifiedName queryName, Predicate<Object> filter, @Nullable Object update)
      Emits given update to subscription queries matching the given queryName and given filter.
      Parameters:
      queryName - The qualified name of the Message.type() to filter on.
      filter - A predicate to filter matching subscription queries based on the raw Message.payload().
      update - The incremental update to emit for subscription queries matching the given filter.
    • emit

      void emit(QualifiedName queryName, Predicate<Object> filter, Supplier<Object> updateSupplier)
      Emits the outcome of the updateSupplier to subscription queries matching the given queryName and given filter.

      The updateSupplier is only invoked whenever there are matching queries.

      Parameters:
      queryName - The qualified name of the Message.type() to filter on.
      filter - A predicate to filter matching subscription queries based on the raw Message.payload().
      updateSupplier - The update supplier to emit for subscription queries matching the given queryName and filter.
    • complete

      <Q> void complete(Class<Q> queryType, Predicate<? super Q> filter)
      Completes subscription queries matching the given queryType and filter.
      Type Parameters:
      Q - The type of the QueryMessage to filter on.
      Parameters:
      queryType - The type of the QueryMessage to filter on.
      filter - A predicate to filter matching subscription queries based on the Message.payload() converted to the given queryType
      Throws:
      MessageTypeNotResolvedException - If the given queryType has no known MessageType equivalent required to filter the Message.payload().
      ConversionException - If the Message.payload() could not be converted to the given queryType to perform the given filter. Will only occur if a MessageType could be found for the given queryType.
    • complete

      void complete(QualifiedName queryName, Predicate<Object> filter)
      Completes subscription queries matching the given queryName and filter.
      Parameters:
      queryName - The qualified name of the Message.type() to filter on.
      filter - A predicate testing the raw Message.payload() as is.
    • completeExceptionally

      <Q> void completeExceptionally(Class<Q> queryType, Predicate<? super Q> filter, Throwable cause)
      Completes subscription queries with the given cause matching given queryType and filter.
      Type Parameters:
      Q - The type of the QueryMessage to filter on.
      Parameters:
      queryType - The type of the QueryMessage to filter on.
      filter - A predicate to filter matching subscription queries based on the Message.payload() converted to the given queryType
      cause - The cause of an error leading to exceptionally complete subscription queries.
      Throws:
      MessageTypeNotResolvedException - If the given queryType has no known MessageType equivalent required to filter the Message.payload().
      ConversionException - If the Message.payload() could not be converted to the given queryType to perform the given filter. Will only occur if a MessageType could be found for the given queryType.
    • completeExceptionally

      void completeExceptionally(QualifiedName queryName, Predicate<Object> filter, Throwable cause)
      Completes subscription queries with the given cause matching given queryName and filter.
      Parameters:
      queryName - The qualified name of the Message.type() to filter on.
      filter - A predicate to filter matching subscription queries based on the raw Message.payload().
      cause - The cause of an error leading to exceptionally complete subscription queries.