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)
| 67 | // newEnforcerWithReader is the test seam: lets unit tests inject a fake |
| 68 | // limitsReader so they don't need a Postgres pool. |
| 69 | func 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 | |
| 79 | func (e *DBEnforcer) Get(ctx context.Context, userID string) (Limits, error) { |
| 80 | if cached, ok := e.cacheGet(userID); ok { |