-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.go
More file actions
29 lines (20 loc) · 986 Bytes
/
options.go
File metadata and controls
29 lines (20 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package keysmith
import (
log "github.com/xraph/go-utils/log"
"github.com/xraph/keysmith/plugin"
"github.com/xraph/keysmith/store"
)
// Option is a functional option for Engine.
type Option func(*Engine)
// WithStore sets the composite store.
func WithStore(s store.Store) Option { return func(e *Engine) { e.store = s } }
// WithHasher sets the key hasher.
func WithHasher(h Hasher) Option { return func(e *Engine) { e.hasher = h } }
// WithKeyGenerator sets the key generator.
func WithKeyGenerator(g KeyGenerator) Option { return func(e *Engine) { e.generator = g } }
// WithRateLimiter sets the rate limiter.
func WithRateLimiter(r RateLimiter) Option { return func(e *Engine) { e.ratelimiter = r } }
// WithExtension registers a lifecycle plugin with the engine.
func WithExtension(x plugin.Plugin) Option { return func(e *Engine) { e.hooks.Register(x) } }
// WithLogger sets the logger.
func WithLogger(l log.Logger) Option { return func(e *Engine) { e.logger = l } }