Java
A Java function is the same function as any other (address, versions, aliases, subscriptions, schedules, settings, promotion), but it is a jar and it runs in the ingestor runtime rather than on the WebAssembly runner. There is no “guest SDK” to compile to WebAssembly: you implement one interface from a small API jar. See JVM functions are hosted by the ingestor runtime for why, and Function runners and engines for the hosting side.
Functions are first-party code (decision). The class loader keeps a function away from the host’s internals, but that is fault isolation, not a sandbox.
Install
Section titled “Install”The function API (io.flowcatalyst.function, artifact io.flowcatalyst.ingestor:function-api) is
not published to Maven Central or any registry. It is built from the platform repository and
installed into your local Maven repository once:
make function-api-install # in a checkout of the platform repositoryYour project then depends on it, and on the FlowCatalyst framework HTTP module, with scope
provided: the host supplies both to every function, so the jar holds only your classes.
<dependency> <groupId>io.flowcatalyst.ingestor</groupId><artifactId>function-api</artifactId> <version>${ingestor-api.version}</version><scope>provided</scope></dependency><dependency> <groupId>io.flowcatalyst.framework</groupId><artifactId>framework-http</artifactId> <version>${flowcatalyst-framework.version}</version><scope>provided</scope></dependency>ingestor-api.version is the version of the ingestor API, which has its own number (currently
1.0.0, in ingestor/API_VERSION, tagged ingestor-api/vX.Y.Z), not the runtime’s: a runtime release
does not change it. Pin the tag you build against. Within a major the API only adds, so a function built
against 1.m runs on every runtime that serves 1.n with n >= m; a function that uses something added
in a later minor needs a runtime that serves it, so deploy the runtime first. To build against a tag,
run ./mvnw -B -DskipTests install -pl ingestor-contract,ingestor-extension,function-api -am in
ingestor/ at that tag.
Declare the function API major your jar was built for in its manifest, with the Maven jar plugin’s
manifestEntries:
<manifestEntries> <Ingestor-Function-Api>1</Ingestor-Function-Api></manifestEntries>The runtime refuses a jar that declares another major, or a value that is not a version, before it
loads any class: the version fails with LOAD:API_MAJOR. A jar that declares nothing is taken as major 1.
Declare it in new builds.
Use JDK 25 (maven.compiler.release 25). The example project is ingestor/examples/function-hello
in the platform repository. Note that JVM functions need an fcdev built from the same checkout
(./bin/fcdev after make build): an older installed fcdev rejects a jar as an invalid Wasm
module.
The Function interface
Section titled “The Function interface”One class with a public no-argument constructor implements io.flowcatalyst.function.Function.
The host creates one instance per published version and calls it for every request at once,
each call on its own virtual thread, so the class must be stateless and thread-safe.
public final class HelloFunction implements Function {
@Override public void init(FunctionContext ctx) { // once, before the first call ctx.logger().log(Level.INFO, "starting {0} v{1}", ctx.address(), ctx.version()); }
@Override public Result handle(Request in, FunctionContext ctx) throws Exception { return switch (in.route()) { // the pattern the describe declares case "GET /healthz" -> Result.json(200, "{\"status\":\"ok\"}"); case "GET /hello/{name}" -> hello(in); case "POST /events/greeting-requested" -> greetingRequested(in, ctx); default -> Result.fail("no handler for " + in.route()); }; }
@Override public void stop() { } // once, after the last call returned}The host routes and authenticates before handle runs, so the path is always one the describe
declares. init and stop have empty defaults.
Request and caller
Section titled “Request and caller”Request carries id(), address(), version(), method(), path(), rawQuery(), headers(),
route() (the matched pattern), pathParams(), caller(), deadline(), host(), remoteAddr(),
isPublic() and the body (body(), bodyText()), with header(name) and query() helpers.
caller() is a sealed Caller, one per endpoint auth:
Endpoint auth |
Caller |
Meaning |
|---|---|---|
webhook |
Caller.Platform |
A verified delivery. Parse the body with Webhook.event(in), Webhook.dataOnly(in) or Webhook.schedule(in) |
platform |
Caller.Principal |
A platform token the host verified: id, type, tier, clients, clientCodes, roles, applications, permissions, with hasPermission, canAccessClient, canAccessClientCode, canAccessApplication, canAccessApplicationCode |
none |
Caller.Anonymous |
Nothing was checked; the function authenticates for itself |
Result
Section titled “Result”| Factory | Answer | A delivery treats it as |
|---|---|---|
Result.ack() |
200 |
delivered |
Result.retry(Duration) |
429 and Retry-After |
try again after the delay, without spending an attempt |
Result.reject(reason) / reject() |
422 and FlowCatalyst-Outcome: reject |
give up now |
Result.fail(reason) |
500 {"error": ...} |
a failed attempt, retried on the schedule |
Result.json(status, json), text(status, s), status(status), http(status, headers, body) |
as given | what an API client receives |
See delivery.
FunctionContext
Section titled “FunctionContext”Everything a function may reach, limited to what its describe declares.
| Service | Notes |
|---|---|
logger() |
A System.Logger carrying function, version and invocation id |
config(), secrets() |
get(key) returns an Optional; require(key) throws if absent. Secrets never appear in toString or logs |
dataSource(name) |
A JDBC DataSource for a declared database. PostgreSQL only. The host keeps one pool per distinct connection string, shared by every function bound to it. Borrow a connection per call and close it |
http() |
HttpCaller.send(HttpCall) returning an HttpReply. Only hosts in httpAllow; HTTPS only (plain HTTP to loopback); redirects are not followed; responses over 16 MiB fail the call |
events().emit(OutboundEvent) |
Only declared types of your application. A dedup id is required. Returns EmitResult.Emitted or EmitResult.Refused (with retryable()); it does not throw for either |
dispatcher().dispatch(DispatchJob) |
Only declared (target, path) pairs; DispatchJob.to(target, path) builder; not de-duplicated. DispatchException.retryable() says whether a retry makes sense |
platformToken(), platformToken(boolean refresh) |
The access token of the application’s linked service account; requires platformToken: true. PlatformTokenException has retryable() |
clock() |
The host’s clock; never read the system clock, so tests can fix time |
address(), version() |
This function and the loaded version |
trace(context, message[, data[, TraceOptions]]), tracing(context), setReference(ref), conceal(value) |
Trace logs, the call’s business key, and keeping run-time credentials out of traces |
Emitting an event, from the example:
OutboundEvent outbound = new OutboundEvent( "hello:greeting:greeting:sent", // type (declared in "emits") "function:" + ctx.address().render(), // source event.subject(), "application/json", sent, event.correlationId(), event.id(), event.messageGroup(), UUID.randomUUID().toString()); // dedupId: derive it from the input in real codereturn switch (ctx.events().emit(outbound)) { case EmitResult.Emitted emitted -> Result.ack(); case EmitResult.Refused refused when refused.retryable() -> Result.retry(Duration.ofSeconds(5)); case EmitResult.Refused refused -> Result.reject("emit refused: " + refused.code());};The example uses a random dedup id for brevity. In a real subscriber derive it from the delivered event so a redelivery emits once.
The describe entry
Section titled “The describe entry”Java has no init() registration, so the declarations live in a file in the jar:
META-INF/flowcatalyst/function.json. It is the same
describe document every function has, plus a jvm block naming
the entrypoint class.
{ "abi": 1, "jvm": { "entrypoint": "io.flowcatalyst.example.hello.HelloFunction" }, "endpoints": [ { "method": "GET", "path": "/healthz", "auth": "none" }, { "method": "GET", "path": "/hello/{name}", "auth": "platform" }, { "method": "POST", "path": "/events/greeting-requested", "auth": "webhook" } ], "subscriptions": [ { "eventType": "hello:greeting:greeting:requested", "path": "/events/greeting-requested", "mode": "IMMEDIATE" } ], "config": ["GREETING"], "emits": ["hello:greeting:greeting:sent"]}An endpoint without method matches every method. Publishing reads this entry without running
anything (at most 1 MiB, at most 50 000 jar entries, the jar at most 64 MiB), validates it like a
Wasm describe, and requires jvm.entrypoint. A jar without the entry is refused.
Build and deploy
Section titled “Build and deploy”Build a jar with Maven (a shade plugin if you bundle dependencies). The host gives you the JDK, the
function API, the framework (io.flowcatalyst.framework.*), the Jackson it exposes
(tools.jackson), SLF4J and jspecify; bundle everything else. A jar containing the API’s own
package, a native library, or a registered java.security.Provider is refused. Then deploy:
fcdev fn deploy hello.greeting target/function-hello-0.1.0.jar --createfcdev fn set hello.greeting --config GREETING=Howdyfcdev fn promote hello.greeting 1The runtime is chosen from the .jar extension and is fixed from the function’s first version
(a mismatch is refused RUNTIME_MISMATCH). The pool, warm and limits are platform settings, not
in the jar. See Publish, promote and use aliases.
Deploying needs a platform whose FC_FUNCTIONS_RUNNER_URL_JVM points at an ingestor with the
function role enabled (INGEST_FUNCTIONS_ENABLED, default true), and the ingestor’s service
account holding platform:function-runner. fcdev start wires this up locally.
Testing
Section titled “Testing”The API jar includes fakes in io.flowcatalyst.function.testing: FakeFunctionContext,
FakeRequest, RecordingEvents, RecordingDispatcher and CapturingLogger. They need no host.
var ctx = FakeFunctionContext.builder(FunctionAddress.parse("hello.greet")) .config("greeting", "Hi").secret("api-key", "s3cr3t").build();Result r = new GreetFunction().handle(FakeRequest.get("/greet/ann").build(), ctx);assertThat(ctx.events().emitted()).hasSize(1);The fake clock is fixed (2026-09-20T00:00:00Z) unless set. http() and dataSource(name) throw
UnsupportedOperationException unless provided; platformToken() answers what you set, or throws
NOT_DECLARED. Every trace call is recorded whether or not its context is live.
A jar cannot be run with fcdev fn run or fcdev fn dev, which run Wasm and JS. To try one
locally, build the platform checkout (make build, make function-hello), start ./bin/fcdev start
and call it on the ingestor’s port (FC_INGESTOR_PORT, default 8091).
Limits and what is missing
Section titled “Limits and what is missing”Concurrency defaults to 16 permits; a call that finds none free is answered 429 FUNCTION_BUSY
with Retry-After: 1 and is never queued. A call past its deadline (endpoint timeoutMs, else the
function’s, default 30 s) is answered 504 FUNCTION_TIMEOUT; an exception is 500 FUNCTION_FAILED
(the exception goes to the host log, not the answer). Log output per function is rate limited.
Not yet built for JVM functions: public routes and domains, per-function metrics and a readiness check.