Skip to content

Extension traits

Dwara defines five swappable subsystem seams as traits. The default OSS build ships a local implementation for each; the enterprise edition adds Redis- and Vault-backed implementations of the same traits. You can also write your own implementation and wire it in -- the gateway calls the trait, not the concrete backend.

The traits are the extraction boundary for promoting a subsystem to its own crate later (see Code organization): each is self-contained behind its trait, so a backend swap is a config change, not a code change.

The five traits

TraitWhat it ownsDefault implEnterprise impl
RateLimiterrate-limit decisions per scopelocal GCRA, stacked windowsRedis-backed distributed GCRA
ConfigSourcewhere config generations come fromfile watch / SIGHUP / admin APIcontroller gRPC stream (CP/DP)
CacheStoreresponse cache get/set/invalidatelocal in-memory, TTL/ETagRedis-backed two-tier distributed cache
AnalyticsSinkwhere completed-request records goembedded SQLite analytics storefederated gRPC stream to controller
SecretSourcehow ${...} secret references resolveenv, file, static inlineHashiCorp Vault and KMS

How they fit together

Each trait is consumed by exactly one domain:

  • RateLimiter is called from the traffic-policy stage of the request pipeline.
  • ConfigSource feeds the snapshot publish pipeline (parse, validate, compile, publish).
  • CacheStore is consulted by the response-caching stage after a route matches.
  • AnalyticsSink receives the fire-and-forget record for every completed request.
  • SecretSource resolves references at compile time, before the snapshot is published.

The local implementations are always available. Enterprise backends are compiled in with the ent cargo feature and activated by a license claim; in an OSS build the enterprise config blocks are accepted and inert. See Feature reference for the gating mechanics.

Runnable demo

The demos/08-extensibility/ README documents the extension-trait surface with a pointer to this page; the demo category's test scripts cover the config-driven plugin families.

Where to go next