MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / DBEnforcer

Struct DBEnforcer

internal/limits/enforcer.go:39–47  ·  view source on GitHub ↗

DBEnforcer is the production Enforcer: reads account_limits + falls back to operator Defaults, counts current resources via the usage store, and caches the resolved Limits in-process for cacheTTL to keep hot paths off the DB on every send. The cache only stores the *Limits* (caps), not the *counts*

Source from the content-addressed store, hash-verified

37// check; the win from caching limits is avoiding the join into
38// account_limits, which is the costlier read.
39type DBEnforcer struct {
40 store limitsReader
41 counter Counter
42 defaults Defaults
43 cacheTTL time.Duration
44
45 mu sync.Mutex
46 cache map[string]cachedLimits
47}
48
49type cachedLimits struct {
50 limits Limits

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected