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(@Nonnull 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(@Nonnull Class<Q> queryType, @Nonnull 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
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      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
      invalid reference
      SubscriptionQueryMessage#payload()
      .
      ConversionException - If the
      invalid reference
      SubscriptionQueryMessage#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(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull 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
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      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
      invalid reference
      SubscriptionQueryMessage#payload()
      .
      ConversionException - If the
      invalid reference
      SubscriptionQueryMessage#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(@Nonnull QualifiedName queryName, @Nonnull 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
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
      update - The incremental update to emit for subscription queries matching the given filter.
    • emit

      void emit(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter, @Nonnull 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
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
      updateSupplier - The update supplier to emit for subscription queries matching the given queryName and filter.
    • complete

      <Q> void complete(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter)
      Completes subscription queries matching the given queryType and filter.
      Type Parameters:
      Q - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      Throws:
      MessageTypeNotResolvedException - If the given queryType has no known MessageType equivalent required to filter the
      invalid reference
      SubscriptionQueryMessage#payload()
      .
      ConversionException - If the
      invalid reference
      SubscriptionQueryMessage#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(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter)
      Completes subscription queries matching the given queryName and filter.
      Parameters:
      queryName - The qualified name of the
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
    • completeExceptionally

      <Q> void completeExceptionally(@Nonnull Class<Q> queryType, @Nonnull Predicate<? super Q> filter, @Nonnull Throwable cause)
      Completes subscription queries with the given cause matching given queryType and filter.
      Type Parameters:
      Q - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      Parameters:
      queryType - The type of the
      invalid reference
      SubscriptionQueryMessage
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      , converted to the given queryType to filter on.
      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
      invalid reference
      SubscriptionQueryMessage#payload()
      .
      ConversionException - If the
      invalid reference
      SubscriptionQueryMessage#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(@Nonnull QualifiedName queryName, @Nonnull Predicate<Object> filter, @Nonnull Throwable cause)
      Completes subscription queries with the given cause matching given queryName and filter.
      Parameters:
      queryName - The qualified name of the
      invalid reference
      SubscriptionQueryMessage#type()
      to filter on.
      filter - A predicate testing the
      invalid reference
      SubscriptionQueryMessage#payload()
      as is to the given queryType to filter on.
      cause - The cause of an error leading to exceptionally complete subscription queries.