Package com.tick42.glue.core.interop.stream.publish

# Interface StreamSubscriptionRequestHandler<T>

Type Parameters:
  `T` - type of the subscription request argument

Functional Interface:
  This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface StreamSubscriptionRequestHandler<T>

Handler for subscription requests.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `static <T> StreamSubscriptionRequestHandler<T>` | `accept()` | Returns a `StreamSubscriptionRequestHandler` that accepts all subscription request and subscribes them to the default stream.
  `static <T> StreamSubscriptionRequestHandler<T>` | `accept​(BiFunction<T,​Instance,​String> streamFunction)` | Returns a `StreamSubscriptionRequestHandler` that accepts all subscription request and subscribes them to a stream with id returned by the provided `streamFunction.apply(arg, caller)`.
  `default StreamSubscriptionRequestHandler<T>` | `andThen​(Function<? super StreamConsumer<T>,​? extends StreamConsumer<T>> fn)` |
  `CompletionStage<StreamConsumer<T>>` | `handle​(StreamSubscriptionRequest<T> request)` | Handle subscription request.
  `default StreamSubscriptionRequestHandler<T>` | `onAdded​(Consumer<? super StreamConsumer<T>> subscriptionAdded)` |
  `default StreamSubscriptionRequestHandler<T>` | `onRemoved​(Consumer<? super StreamConsumer<T>> subscriptionRemoved)` |

- ## Method Details

  - ### accept

    static <T> StreamSubscriptionRequestHandler<T> accept()
    Returns a `StreamSubscriptionRequestHandler` that accepts all subscription request and subscribes them to the default stream.
    Type Parameters:
      `T` - type of the subscription request argument
    Returns:
      a subscription request handler, never `null`

  - ### accept

    static <T> StreamSubscriptionRequestHandler<T> accept​(BiFunction<T,​Instance,​String> streamFunction)
    Returns a `StreamSubscriptionRequestHandler` that accepts all subscription request and subscribes them to a stream with id returned by the provided `streamFunction.apply(arg, caller)`.
    Type Parameters:
      `T` - type of the subscription request argument
    Parameters:
      `streamFunction` - function that accepts request `arg` and `caller` instance and returns stream id
    Returns:
      a subscription request handler, never `null`

  - ### handle

    CompletionStage<StreamConsumer<T>> handle​(StreamSubscriptionRequest<T> request)
    Handle subscription request.

    The request can be `accepted (on main stream)`, `accepted on stream` or `rejected`.

    Parameters:
      `request` - subscription request to handle
    Returns:
      a stage that completes with a `StreamConsumer` when the request is accepted and completes exceptionally with a `StreamSubscriptionRejectedException` when the request is rejected

  - ### onAdded

    default StreamSubscriptionRequestHandler<T> onAdded​(Consumer<? super StreamConsumer<T>> subscriptionAdded)

  - ### onRemoved

    default StreamSubscriptionRequestHandler<T> onRemoved​(Consumer<? super StreamConsumer<T>> subscriptionRemoved)

  - ### andThen

    default StreamSubscriptionRequestHandler<T> andThen​(Function<? super StreamConsumer<T>,​? extends StreamConsumer<T>> fn)