2018-12-29 18:44:51 +03:00
|
|
|
package registry
|
2016-05-03 21:26:50 +03:00
|
|
|
|
|
|
|
import (
|
2018-03-03 14:53:52 +03:00
|
|
|
"context"
|
2016-05-03 21:26:50 +03:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/micro/go-micro/selector"
|
|
|
|
)
|
|
|
|
|
2018-12-29 18:44:51 +03:00
|
|
|
// Set the registry cache ttl
|
2016-05-03 21:26:50 +03:00
|
|
|
func TTL(t time.Duration) selector.Option {
|
|
|
|
return func(o *selector.Options) {
|
|
|
|
if o.Context == nil {
|
|
|
|
o.Context = context.Background()
|
|
|
|
}
|
2018-12-29 18:44:51 +03:00
|
|
|
o.Context = context.WithValue(o.Context, "selector_ttl", t)
|
2016-05-03 21:26:50 +03:00
|
|
|
}
|
|
|
|
}
|