public interface StatefulFunctionModule
StatefulFunctionModule
is the entry point for adding to a Stateful Functions
application the core building block primitives, i.e. IngressSpec
s, EgressSpec
s,
Router
s, and StatefulFunction
s.
A Stateful Functions application is built up of ingresses, egresses, routers, and stateful
functions that are added to the application by multiple different StatefulFunctionModule
s. This allows different parts of the application to be contributed by
different modules; for example, one module may provide ingresses and egresses, while other
modules may individually contribute specific parts of the application as stateful functions.
The extensibility is achieved by leveraging the Java Service Loader. In this context, each module is essentially a service provider.
StatefulFunctionModule
In order for an application to discover a given module, likewise to how the Java Service
Loader works, a UTF-8 encoded provider configuration file needs to be stored in the META-INF/services
directory of the module's containing JAR file. The name of the file should be
org.apache.flink.statefun.sdk.spi.StatefulFunctionModule
, i.e. the fully qualified name
of the StatefulFunctionModule
class. Each line in the file should be the fully qualified
class name of a module in that JAR that you want to register for the Stateful Functions
application. The configuration file may also be automatically generated using Google's AutoService tool.
Finally, to allow the Stateful Functions runtime to discover the registered modules, the JAR
files containing the modules and provider configuration files should be added to a
system-specific class path directory, /opt/statefun/modules/
.
For a simple demonstration, you can consult the statefun-greeter-example
example.
Modifier and Type | Interface and Description |
---|---|
static interface |
StatefulFunctionModule.Binder
A
StatefulFunctionModule.Binder binds ingresses, egresses, routers, and functions to a Stateful Functions
application. |
Modifier and Type | Method and Description |
---|---|
void |
configure(java.util.Map<java.lang.String,java.lang.String> globalConfiguration,
StatefulFunctionModule.Binder binder)
This method is the entry point for extending a Stateful Functions application by binding
ingresses, egresses, routers, and functions.
|
void configure(java.util.Map<java.lang.String,java.lang.String> globalConfiguration, StatefulFunctionModule.Binder binder)
globalConfiguration
- global configuration of the Stateful Functions application.binder
- the binder to be used to bind ingresses, egresses, routers, and functions.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.