mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-23 10:45:25 -05:00
33 lines
741 B
Go
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)
|
|
}
|
|
}
|