WACElib supports three execution modes for model plugins, each with different latency, network, and reliability characteristics. Choosing the right mode depends on whether your model runs in-process alongside WACElib, whether it runs as a remote service reachable over NATS, and whether its result needs to influence the blocking decision for the current request. All three modes are configured per plugin in your YAML configuration and are loaded at startup byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tilsor/ModSecIntl_wace_lib/llms.txt
Use this file to discover all available pages before exploring further.
Init.
How modes are selected
WhenInit loads a plugin, it reads two fields from each entry in modelplugins:
mode— either"sync"or"async"remote—trueorfalse(defaultfalse)
callPlugins:
mode | remote | Execution path |
|---|---|---|
sync | false | plugins.Process() called directly in a goroutine |
sync | true | Payload published to NATS; result awaited on channel |
async | false | Payload published to NATS; result not awaited |
async | true | Payload published to NATS; result not awaited |
The three modes
- Sync local
- Sync remote
- Async
Sync local (When to use: Your ML model is a compiled Go plugin (
mode: sync, remote: false) is the default in-process execution path. When callPlugins encounters a sync, non-remote plugin, it calls plugins.Process(modelID, transactionID, payload, pluginType, modelPluginStatus) in a goroutine. Process calls the plugin’s exported Process(ModelInput) (ModelResults, error) function directly, stores the result in the transaction’s results map, and sends a ModelStatus onto the channel. CheckTransaction waits for this status before calling the decision plugin.This mode has the lowest latency because there is no serialization or network hop — the model executes in the same process as WACElib.Plugin initialization: sync local plugins export InitPlugin(map[string]string, metric.Meter) error and Process(ModelInput) (ModelResults, error)..so) that can run inside the WACElib process, and you need the result to influence the current request’s block decision with minimal latency.NATS connection setup
Both sync remote and async modes require a running NATS server. WACElib’sPluginManager establishes a single connection at startup using the NatsURL field from ConfigStore, which defaults to "localhost:4222" if omitted from the configuration file.
- Inbound (WACElib → model): subject is the model
idfield (e.g.,deepInspect) - Outbound (model → WACElib): subject is
<modelID>/results(e.g.,deepInspect/results)
ModelResultsHandler goroutine subscribed to its <modelID>/results subject. This goroutine runs for the lifetime of the process.
Plugin function signatures
WACElib uses Go’splugin package to load .so files. The exported symbols it looks up depend on the mode:
register callback passed to InitPluginAsync connects the plugin’s process function to ModelProcessHandler, which subscribes to the NATS subject and handles inbound payloads.