Documentation 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 is the single entry point that wires together the entire WACElib runtime. It must be called exactly once before any transaction is processed. Internally it calls configstore.New() to create the singleton config store, applies the supplied ConfigFileData, initialises the structured logger at the requested path and level, and then constructs the PluginManager which loads every model and decision .so plugin listed in the configuration.
Signature
Parameters
An OpenTelemetry
metric.Meter used to record per-model histogram durations
(wace.model.duration.nanoseconds) and blocked-request counters
(wace.client.request.blocked.total). Obtain one from a
metric.MeterProvider.Parsed configuration data. Typically populated by unmarshalling a YAML config
file into a
ConfigFileData struct. See the
configstore reference for all fields.Return value
Returnsnil on success. Returns an error if:
- A
ConfigStoreinstance already exists (i.e.Initwas called twice). - The configuration is invalid (bad log path, missing plugin paths, unknown plugin types).
- The logger cannot open the log file.
- The
PluginManagerfails to construct.
Example
Startup sequence
Init performs the following steps in order:
- Calls
configstore.New()to create the singletonConfigStore. Returns an error immediately if one already exists. - Calls
cs.SetConfig(conf)to validate and load the configuration into the store. - Stores the
metric.Meterreference for later use in transaction processing. - Calls
logger.LoadLogger(cs.LogPath, cs.LogLevel)to open the log file. - Calls
pluginmanager.New(met)to load all.soplugins declared in the configuration and establish NATS connections for async/remote plugins.
The
metric.Meter instance you pass to Init is stored as a package-level
variable and reused for all subsequent transaction metrics. Pass a no-op meter
(e.g. metric.NewMeterProvider().Meter("")) during testing if you do not need
telemetry.