mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-08 04:20:59 -05:00
73c99cce9e
Signed-off-by: jkoberg <jkoberg@owncloud.com>
33 lines
744 B
Go
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)
|
|
}
|
|
}
|