Files
opencloud/ocis-pkg/natsjsregistry/options.go
T
jkoberg 73c99cce9e introduce natsjs registry
Signed-off-by: jkoberg <jkoberg@owncloud.com>
2023-11-06 08:59:01 +01:00

33 lines
744 B
Go

package natsjsregistry
import (
"context"
"time"
"go-micro.dev/v4/registry"
"go-micro.dev/v4/store"
)
type storeOptionsKey struct{}
type expiryKey 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)
}
}
// ServiceExpiry allows setting an expiry time for service registrations
func ServiceExpiry(t time.Duration) registry.Option {
return func(o *registry.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, expiryKey{}, t)
}
}