1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00
go-micro/store/options.go

48 lines
832 B
Go
Raw Normal View History

2019-06-12 08:46:20 +02:00
package store
2019-06-11 18:20:52 +02:00
import (
2019-12-16 16:38:51 +02:00
"context"
2019-06-11 18:20:52 +02:00
)
type Options struct {
// nodes to connect to
Nodes []string
// Namespace of the store
Namespace string
// Prefix of the keys used
Prefix string
2019-12-16 16:38:51 +02:00
// Alternative options
Context context.Context
}
2019-12-16 16:38:51 +02:00
type Option func(o *Options)
2019-11-01 16:13:21 +02:00
// Nodes is a list of nodes used to back the store
2019-12-16 16:38:51 +02:00
func Nodes(a ...string) Option {
return func(o *Options) {
o.Nodes = a
}
2019-06-11 18:20:52 +02:00
}
// Prefix sets a prefix to any key ids used
2019-12-16 16:38:51 +02:00
func Prefix(p string) Option {
return func(o *Options) {
o.Prefix = p
}
2019-06-11 18:20:52 +02:00
}
2019-11-01 16:13:21 +02:00
// Namespace offers a way to have multiple isolated
// stores in the same backend, if supported.
2019-12-16 16:38:51 +02:00
func Namespace(ns string) Option {
return func(o *Options) {
o.Namespace = ns
}
2019-11-01 16:13:21 +02:00
}
// ReadPrefix uses the key as a prefix
func ReadPrefix() ReadOption {
return func(o *ReadOptions) {
o.Prefix = true
}
}