2020-12-08 00:58:12 +03:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
2021-05-08 17:07:32 +03:00
|
|
|
"time"
|
|
|
|
|
2020-12-08 00:58:12 +03:00
|
|
|
"github.com/hashicorp/consul/api"
|
2021-10-26 23:00:25 +03:00
|
|
|
"go.unistack.org/micro/v3/config"
|
2020-12-08 00:58:12 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type configKey struct{}
|
|
|
|
|
|
|
|
func Config(cfg *api.Config) config.Option {
|
|
|
|
return config.SetOption(configKey{}, cfg)
|
|
|
|
}
|
|
|
|
|
|
|
|
type tokenKey struct{}
|
|
|
|
|
|
|
|
func Token(token string) config.Option {
|
|
|
|
return config.SetOption(tokenKey{}, token)
|
|
|
|
}
|
|
|
|
|
|
|
|
type addrKey struct{}
|
|
|
|
|
|
|
|
func Address(addr string) config.Option {
|
|
|
|
return config.SetOption(addrKey{}, addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
type pathKey struct{}
|
|
|
|
|
|
|
|
func Path(path string) config.Option {
|
|
|
|
return config.SetOption(pathKey{}, path)
|
|
|
|
}
|
2020-12-09 13:21:48 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
type tlsConfigKey struct{}
|
|
|
|
|
|
|
|
func TLSConfig(t *tls.Config) config.Option {
|
|
|
|
return config.SetOption(tlsConfigKey{}, t)
|
|
|
|
}
|
|
|
|
*/
|
2021-05-08 17:07:32 +03:00
|
|
|
|
|
|
|
type timeoutKey struct{}
|
|
|
|
|
|
|
|
func Timeout(td time.Duration) config.Option {
|
|
|
|
return config.SetOption(timeoutKey{}, td)
|
|
|
|
}
|