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"
|
2023-08-14 23:36:40 +03:00
|
|
|
"go.unistack.org/micro/v4/options"
|
2020-12-08 00:58:12 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type configKey struct{}
|
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func Config(cfg *api.Config) options.Option {
|
|
|
|
return options.ContextOption(configKey{}, cfg)
|
2020-12-08 00:58:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type tokenKey struct{}
|
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func Token(token string) options.Option {
|
|
|
|
return options.ContextOption(tokenKey{}, token)
|
2020-12-08 00:58:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type addrKey struct{}
|
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func Address(addr string) options.Option {
|
|
|
|
return options.ContextOption(addrKey{}, addr)
|
2020-12-08 00:58:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type pathKey struct{}
|
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func Path(path string) options.Option {
|
|
|
|
return options.ContextOption(pathKey{}, path)
|
2020-12-08 00:58:12 +03:00
|
|
|
}
|
2020-12-09 13:21:48 +03:00
|
|
|
|
2021-05-08 17:07:32 +03:00
|
|
|
type timeoutKey struct{}
|
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func Timeout(td time.Duration) options.Option {
|
|
|
|
return options.ContextOption(timeoutKey{}, td)
|
2021-05-08 17:07:32 +03:00
|
|
|
}
|
2021-11-18 16:05:44 +03:00
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
/*
|
|
|
|
type tlsConfigKey struct{}
|
2021-11-18 16:05:44 +03:00
|
|
|
|
2023-08-14 23:36:40 +03:00
|
|
|
func TLSConfig(t *tls.Config) options.Option {
|
|
|
|
return options.ContextOption(tlsConfigKey{}, t)
|
2021-11-18 16:05:44 +03:00
|
|
|
}
|
2023-08-14 23:36:40 +03:00
|
|
|
*/
|