Files
opencloud/pkg/natsjsregistry/options.go
Jörn Friedrich Dreyer b07b5a1149 use plain pkg module
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
2025-01-13 16:42:19 +01:00

33 lines
741 B
Go

package natsjsregistry
import (
"context"
"time"
"go-micro.dev/v4/registry"
"go-micro.dev/v4/store"
)
type storeOptionsKey struct{}
type defaultTTLKey struct{}
// StoreOptions sets the options for the underlying store
func StoreOptions(opts []store.Option) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, storeOptionsKey{}, opts)
}
}
// DefaultTTL allows setting a default register TTL for services
func DefaultTTL(t time.Duration) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, defaultTTLKey{}, t)
}
}