Interface StreamedCommandContext<Output>

    • Method Detail

      • isStreamed

        boolean isStreamed()
        Whether the call is actually streamed.

        When a command is handled via the HTTP adapter, the command will not be streamed since the HTTP adapter does not support streaming, and this will return false. In that case, calls to onChange(Function) and onCancel(Consumer) will fail.

        Returns:
        True if the command is actually streamed.
      • onChange

        void onChange​(java.util.function.Function<SubscriptionContext,​java.util.Optional<Output>> subscriber)
        Register an on change callback for this command.

        The callback will be invoked any time the CRDT changes. The callback may inspect the CRDT, but any attempt to modify the CRDT will be ignored and the CRDT will crash.

        If the callback returns a value, that value will be sent down the stream. Alternatively, the callback may forward messages to other entities via the passed in SubscriptionContext. The callback may also emit side effects to other entities via that context.

        Parameters:
        subscriber - The subscriber callback.
      • onCancel

        void onCancel​(java.util.function.Consumer<StreamCancelledContext> effect)
        Register an on cancel callback for this command.

        This will be invoked if the client initiates a stream cancel. It will not be invoked if the entity cancels the stream itself via SubscriptionContext.endStream() from an onChange(Function) callback.

        An on cancel callback may update the CRDT, and may emit side effects via the passed in StreamCancelledContext.

        Parameters:
        effect - The effect to perform when this stream is cancelled.