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

Function newEnforcerWithReader

internal/limits/enforcer.go:69–77  ·  view source on GitHub ↗

newEnforcerWithReader is the test seam: lets unit tests inject a fake limitsReader so they don't need a Postgres pool.

(reader limitsReader, counter Counter, defaults Defaults, cacheTTL time.Duration)

Source from the content-addressed store, hash-verified

67// newEnforcerWithReader is the test seam: lets unit tests inject a fake
68// limitsReader so they don't need a Postgres pool.
69func newEnforcerWithReader(reader limitsReader, counter Counter, defaults Defaults, cacheTTL time.Duration) *DBEnforcer {
70 return &DBEnforcer{
71 store: reader,
72 counter: counter,
73 defaults: defaults,
74 cacheTTL: cacheTTL,
75 cache: make(map[string]cachedLimits),
76 }
77}
78
79func (e *DBEnforcer) Get(ctx context.Context, userID string) (Limits, error) {
80 if cached, ok := e.cacheGet(userID); ok {

Calls 1

makeFunction · 0.85