Interface StreamedCommandContext<Output>
-
- All Superinterfaces:
ClientActionContext,CommandContext,Context,CrdtContext,CrdtFactory,EffectContext,EntityContext
public interface StreamedCommandContext<Output> extends CommandContext
Context for handling a streamed command.This may be passed to any
CommandHandlerannotated element that corresponds to a command whose output is streamed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanisStreamed()Whether the call is actually streamed.voidonCancel(java.util.function.Consumer<StreamCancelledContext> effect)Register an on cancel callback for this command.voidonChange(java.util.function.Function<SubscriptionContext,java.util.Optional<Output>> subscriber)Register an on change callback for this command.-
Methods inherited from interface io.cloudstate.javasupport.ClientActionContext
fail, forward
-
Methods inherited from interface io.cloudstate.javasupport.crdt.CommandContext
commandId, commandName, delete
-
Methods inherited from interface io.cloudstate.javasupport.Context
serviceCallFactory
-
Methods inherited from interface io.cloudstate.javasupport.crdt.CrdtContext
state
-
Methods inherited from interface io.cloudstate.javasupport.crdt.CrdtFactory
newFlag, newGCounter, newGSet, newLWWRegister, newORMap, newORSet, newPNCounter, newVote
-
Methods inherited from interface io.cloudstate.javasupport.EffectContext
effect, effect
-
Methods inherited from interface io.cloudstate.javasupport.EntityContext
entityId
-
-
-
-
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 toonChange(Function)andonCancel(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 anonChange(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.
-
-