Skip to main content

ConfigManager

ConfigManager holds the server-driven configuration for Sentinel and evaluates which outbound URLs should be protected (enriched with sentinel context and/or encrypted).

Responsibilities

ResponsibilityDetail
Store configMaintains the current SentinelConfig in memory
Normalise configCoerces partial / malformed server responses to safe defaults
Path matchingCompiles include/exclude regex patterns and evaluates URLs
Expose accessorsSimple getters for enabled, thresholds, and bucket sizes

Default Configuration

If no config has been received from the server, everything is disabled:

const DEFAULT_CONFIG: SentinelConfig = {
enabled: false,
contextSignalTypeSize: 0,
signalThresholdMs: 0,
signalThresholdSize: 0,
paths: [],
};

Config Shape

interface SentinelConfig {
enabled: boolean;
contextSignalTypeSize: number;
signalThresholdMs: number;
signalThresholdSize: number;
paths: Array<SentinelPathConfig>;
}

interface SentinelPathConfig {
includedPaths: Array<string>; // regex patterns
excludedPaths: Array<string>; // regex patterns
}

Public API

MethodReturnDescription
update(config?)voidMerge partial config into current state
getConfig()SentinelConfigDeep-copy of current config
isEnabled()booleanWhether signal collection is active
getContextSignalTypeSize()numberMax signals per type in the context bucket
getSignalThresholdMs()numberTime-based flush interval
getSignalThresholdSize()numberSize-based flush threshold
shouldProtectResource(url)booleanWhether the URL should be sentinel-protected

Path Matching Logic

shouldProtectResource(url) determines if an outgoing request should carry sentinel context and/or be encrypted.

Evaluation order

  1. Sentinel internal URLs (/api/sen/…, /api/dfp/…) are always protected regardless of config.
  2. If Sentinel is disabled or no path matchers are configured → false.
  3. Extract pathname from the URL.
  4. For each path config:
    • If includedPaths is non-empty, the pathname must match at least one include pattern.
    • If matched, the pathname must not match any excludedPaths pattern.
  5. Returns true on the first matching path config.

Pattern compilation

Path strings are compiled to RegExp at config update time. Invalid regex patterns are silently dropped.

Normalisation Rules

When update() receives a partial config:

FieldRule
enabledMust be a boolean; otherwise falls back to previous value
contextSignalTypeSizeCoerced to Number; if NaN or negative, uses previous value
signalThresholdMsSame as above
signalThresholdSizeSame as above
pathsMust be an Array; each entry's includedPaths/excludedPaths are filtered to non-empty strings

The server API returns threshold values as strings (e.g. "5000"); normalisation handles this via Number() coercion.

Usage Within Sentinel

ConfigManager is never used standalone. The Sentinel class calls:

this.configManager.update(config);
this.signalStore.setBucketSize(this.configManager.getContextSignalTypeSize());
this.reporter.setThresholds({
timeThresholdMs: this.configManager.getSignalThresholdMs(),
sizeThreshold: this.configManager.getSignalThresholdSize(),
});
this.configManager.isEnabled() ? this.start() : this.stop();

This happens both at initialisation and whenever the reporter returns an updated config from the server.


Last updated: 2026-02-24