Class LocalExecution
- All Implemented Interfaces:
LocalHandlerInput
This is a Fluxzero infrastructure type. It is public so dispatch interceptors, handler registries, and parameter resolvers in different SDK packages can cooperate on the same lazy invocation. Applications should not construct, retain, or reuse an instance. An execution is confined to the invoking thread and its contents are valid only while that invocation is active.
-
Method Summary
Modifier and TypeMethodDescriptionvoidStores a synchronously completed handler value in this execution.voidcompleteAsync(CompletableFuture<?> future) Stores an asynchronous handler result in this execution.voidcompleteExceptionally(Throwable error) Stores a handler failure in this execution.booleancontainsMetadata(String key) Tests already available metadata without forcing deferred metadata creation.static DeserializingMessageReturns the message for the active payload-first invocation on this thread.getIndex()Returns the message index when the local input represents a stored message.Returns the message for this invocation, materializing it when necessary.Returns the message only if it has already been materialized.io.fluxzero.common.MessageTypeReturns the type of message being handled.io.fluxzero.common.api.MetadataReturns the local message metadata, computing deferred metadata changes when necessary.Returns the payload for this invocation without materializing its message.Returns the synchronously completed handler value.getUser(UserProvider provider) Returns the user selected for this local dispatch.static LocalExecutionhandle(Object payload, io.fluxzero.common.MessageType messageType, String topic, Serializer serializer, PreparedLocalDispatch dispatch, HandlerRegistry registry) Attempts to handle a payload through the prepared local path.booleanReturns whether user resolution has already completed for this input.invoke(io.fluxzero.common.handling.HandlerMethodPlan<DeserializingMessage> plan) Invokes a prepared handler plan while installing the required local handling context.booleanReturns whether handling completed synchronously without throwing.static voidMarks batch-scoped message state as used by the active payload-first handler.voidvoidStores the user selected during dispatch for later handler-parameter resolution.
-
Method Details
-
handle
public static LocalExecution handle(Object payload, io.fluxzero.common.MessageType messageType, String topic, Serializer serializer, PreparedLocalDispatch dispatch, HandlerRegistry registry) Attempts to handle a payload through the prepared local path.This infrastructure method returns
nullwhen prepared handling is unsafe in the current context or when the registry requests the regular message-based path. A non-null execution contains the completed local result and must be followed byreleaseResult()after the result has been consumed.- Parameters:
payload- the dispatched payloadmessageType- the type of message being dispatchedtopic- the dispatch topic, ornullserializer- the serializer used if a complete message becomes necessarydispatch- the prepared dispatch-interceptor policyregistry- the local handler registry- Returns:
- the completed execution, or
nullto use regular message-based dispatch
-
complete
Stores a synchronously completed handler value in this execution.- Parameters:
value- the value returned by the handler
-
completeAsync
Stores an asynchronous handler result in this execution.- Parameters:
future- the handler result future
-
completeExceptionally
Stores a handler failure in this execution.- Parameters:
error- the handling error
-
isCompletedSuccessfully
public boolean isCompletedSuccessfully()Returns whether handling completed synchronously without throwing.- Returns:
truewhengetResult()contains the synchronous result
-
getResult
Returns the synchronously completed handler value.- Returns:
- the handler value, which may be
null
-
getResultFuture
-
getResultMessage
-
releaseResult
public void releaseResult() -
currentMessage
Returns the message for the active payload-first invocation on this thread.Calling this method materializes the message if necessary.
- Returns:
- the active local message, or
nulloutside a payload-first invocation
-
markBatchContextUsed
public static void markBatchContextUsed()Marks batch-scoped message state as used by the active payload-first handler.This infrastructure hook ensures that batch callbacks and resources are completed after the invocation.
-
getPayload
Returns the payload for this invocation without materializing its message.- Returns:
- the payload; never
nullwhile the execution is active
-
getMessage
Returns the message for this invocation, materializing it when necessary.- Returns:
- the message being handled
-
getMessageIfAvailable
Returns the message only if it has already been materialized.- Returns:
- the existing message, or
nullif it has not been created yet
-
getMessageType
public io.fluxzero.common.MessageType getMessageType()Returns the type of message being handled.- Specified by:
getMessageTypein interfaceLocalHandlerInput- Returns:
- the current message type
-
getUser
Returns the user selected for this local dispatch.- Specified by:
getUserin interfaceLocalHandlerInput- Parameters:
provider- the configured provider whose user is requested- Returns:
- the resolved user, or
nullif the dispatch has no user
-
setUser
Stores the user selected during dispatch for later handler-parameter resolution.- Parameters:
user- the selected user, ornull
-
hasResolvedUser
public boolean hasResolvedUser()Returns whether user resolution has already completed for this input.- Specified by:
hasResolvedUserin interfaceLocalHandlerInput- Returns:
truewhenLocalHandlerInput.getUser(UserProvider)can be used without materializing the message
-
getMetadata
public io.fluxzero.common.api.Metadata getMetadata()Returns the local message metadata, computing deferred metadata changes when necessary.- Specified by:
getMetadatain interfaceLocalHandlerInput- Returns:
- the current metadata
-
containsMetadata
Tests already available metadata without forcing deferred metadata creation.- Specified by:
containsMetadatain interfaceLocalHandlerInput- Parameters:
key- the metadata key to look up- Returns:
trueif already available metadata contains the key
-
getIndex
Returns the message index when the local input represents a stored message.- Specified by:
getIndexin interfaceLocalHandlerInput- Returns:
- the message index, or
nullfor a newly dispatched local message
-
invoke
Invokes a prepared handler plan while installing the required local handling context.- Specified by:
invokein interfaceLocalHandlerInput- Parameters:
plan- the handler plan to invoke- Returns:
- the handler result
-