public interface StatefulFunction
StatefulFunction
is a user-defined function that can be invoked with a given input.
This is the primitive building block for a Stateful Functions application.
Each individual StatefulFunction
is an uniquely invokable "instance" of a registered
StatefulFunctionSpec
. Each instance is identified by an Address
, representing the
function's unique id (a string) within its type. From a user's perspective, it would seem as if
for each unique function id, there exists a stateful instance of the function that is always
available to be invoked within a Stateful Functions application.
StatefulFunction
An individual StatefulFunction
can be invoked with arbitrary input from any another
StatefulFunction
(including itself), or routed from ingresses. To invoke a StatefulFunction
, the caller simply needs to know the Address
of the target function.
As a result of invoking a StatefulFunction
, the function may continue to invoke other
functions, access persisted values, or send messages to egresses.
Each individual StatefulFunction
may have persistent values written to storage that is
maintained by the system, providing consistent exactly-once and fault-tolerant guarantees. Please
see Javadocs in ValueSpec
and AddressScopedStorage
for an overview of how to
register persistent values and access the storage.
Address
,
StatefulFunctionSpec
,
ValueSpec
,
AddressScopedStorage
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
apply(Context context,
Message argument)
Applies an input message to this function.
|
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.