Skip to main content

preload

Attribute Macro preload 

Source
#[preload]
Expand description

The Java @PreLoad(route, instances, envInstances) analog: registers a composable function at startup.

Parameters:

  • route = "my.function.route" (required). A comma-separated list registers the same function under several route names (aliases) with the same instance count and visibility — the Java @PreLoad(route = "hello.world, hello.declarative") behavior. Each name is whitespace-trimmed; an empty segment is a compile error.
  • instances = N (default 1)
  • env_instances = "config.key" — read the instance count from application configuration at startup, falling back to instances (Java envInstances)
  • is_private = false — a PUBLIC function, callable from another application instance through Event over HTTP. Java @PreLoad parity: preloaded functions are private by default (in-instance only); opt into public visibility explicitly (Java isPrivate = false)
  • typed — the struct implements TypedFunction<I, O>; it is wrapped in a TypedAdapter (without this flag the struct must implement ComposableFunction)

Consumed marker attributes (place them below #[preload]):

  • #[zero_tracing] — the Java @ZeroTracing: this route’s executions are excluded from distributed-trace recording.
  • #[event_interceptor] — the Java @EventInterceptor: the function receives the raw envelope (reply_to/cid intact) and replies manually via po.send; the worker sends no auto-reply on success (also available as the interceptor flag parameter).
  • #[optional_service("condition")] — see [optional_service]: a first-class attribute that also works stacked above this one.

The struct must be a unit struct or implement Default.