documentation: mention Register functions should be call at init time (#1975)

This commit is contained in:
Menghan Li
2018-04-12 15:11:04 -07:00
committed by lyuxuan
parent 0c6b34bbc3
commit c4a6e7589b
2 changed files with 12 additions and 5 deletions

View File

@ -36,9 +36,12 @@ var (
m = make(map[string]Builder) m = make(map[string]Builder)
) )
// Register registers the balancer builder to the balancer map. // Register registers the balancer builder to the balancer map. b.Name
// b.Name (lowercased) will be used as the name registered with // (lowercased) will be used as the name registered with this builder.
// this builder. //
// NOTE: this function must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe. If multiple Balancers are
// registered with the same name, the one registered last will take effect.
func Register(b Builder) { func Register(b Builder) {
m[strings.ToLower(b.Name())] = b m[strings.ToLower(b.Name())] = b
} }

View File

@ -29,8 +29,12 @@ var (
// TODO(bar) install dns resolver in init(){}. // TODO(bar) install dns resolver in init(){}.
// Register registers the resolver builder to the resolver map. // Register registers the resolver builder to the resolver map. b.Scheme will be
// b.Scheme will be used as the scheme registered with this builder. // used as the scheme registered with this builder.
//
// NOTE: this function must only be called during initialization time (i.e. in
// an init() function), and is not thread-safe. If multiple Resolvers are
// registered with the same name, the one registered last will take effect.
func Register(b Builder) { func Register(b Builder) {
m[b.Scheme()] = b m[b.Scheme()] = b
} }