diff --git a/selector/blacklist/black_list_selector.go b/selector/blacklist/black_list_selector.go index b094ef97..b33d5e4c 100644 --- a/selector/blacklist/black_list_selector.go +++ b/selector/blacklist/black_list_selector.go @@ -5,6 +5,7 @@ import ( "sync" "time" + "github.com/micro/go-micro/cmd" "github.com/micro/go-micro/registry" "github.com/micro/go-micro/selector" ) @@ -26,6 +27,7 @@ type blackListSelector struct { } func init() { + cmd.Selectors["blacklist"] = NewSelector rand.Seed(time.Now().Unix()) } diff --git a/selector/random/random.go b/selector/random/random.go index c3ca6202..57e325cc 100644 --- a/selector/random/random.go +++ b/selector/random/random.go @@ -1,6 +1,13 @@ package random -import "github.com/micro/go-micro/selector" +import ( + "github.com/micro/go-micro/cmd" + "github.com/micro/go-micro/selector" +) + +func init() { + cmd.Selectors["random"] = NewSelector +} func NewSelector(opts ...selector.Option) selector.Selector { return selector.NewSelector(opts...) diff --git a/selector/roundrobin/round_robin_selector.go b/selector/roundrobin/round_robin_selector.go index 0bbed58c..fa984afc 100644 --- a/selector/roundrobin/round_robin_selector.go +++ b/selector/roundrobin/round_robin_selector.go @@ -3,6 +3,7 @@ package roundrobin import ( "sync" + "github.com/micro/go-micro/cmd" "github.com/micro/go-micro/registry" "github.com/micro/go-micro/selector" ) @@ -11,6 +12,10 @@ type roundRobinSelector struct { so selector.Options } +func init() { + cmd.Selectors["roundrobin"] = NewSelector +} + func (r *roundRobinSelector) Select(service string, opts ...selector.SelectOption) (selector.Next, error) { var sopts selector.SelectOptions for _, opt := range opts { @@ -68,7 +73,7 @@ func (r *roundRobinSelector) Close() error { return nil } -func NewRoundRobinSelector(opts ...selector.Option) selector.Selector { +func NewSelector(opts ...selector.Option) selector.Selector { var sopts selector.Options for _, opt := range opts {