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

Function NewEnforcer

internal/limits/enforcer.go:57–65  ·  view source on GitHub ↗

NewEnforcer constructs the production enforcer. cacheTTL of 0 disables the cache (every Get hits the DB) — useful for tests that mutate account_limits and want immediate visibility.

(store *Store, counter Counter, defaults Defaults, cacheTTL time.Duration)

Source from the content-addressed store, hash-verified

55// the cache (every Get hits the DB) — useful for tests that mutate
56// account_limits and want immediate visibility.
57func NewEnforcer(store *Store, counter Counter, defaults Defaults, cacheTTL time.Duration) *DBEnforcer {
58 return &DBEnforcer{
59 store: store,
60 counter: counter,
61 defaults: defaults,
62 cacheTTL: cacheTTL,
63 cache: make(map[string]cachedLimits),
64 }
65}
66
67// newEnforcerWithReader is the test seam: lets unit tests inject a fake
68// limitsReader so they don't need a Postgres pool.

Callers 10

TestServerFunction · 0.92
NewEventsAPIHarnessFunction · 0.92
StartContractServerFunction · 0.92
newConsentFixtureFunction · 0.92
setupAPIWithLimitsFunction · 0.92
mainFunction · 0.92

Calls 1

makeFunction · 0.85