Initialise the command stuff

This commit is contained in:
Asim 2015-12-09 19:38:50 +00:00
parent 2753520ee4
commit 8e2dbb8997
3 changed files with 16 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/micro/go-micro/cmd"
"github.com/micro/go-micro/registry" "github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector" "github.com/micro/go-micro/selector"
) )
@ -26,6 +27,7 @@ type blackListSelector struct {
} }
func init() { func init() {
cmd.Selectors["blacklist"] = NewSelector
rand.Seed(time.Now().Unix()) rand.Seed(time.Now().Unix())
} }

View File

@ -1,6 +1,13 @@
package random 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 { func NewSelector(opts ...selector.Option) selector.Selector {
return selector.NewSelector(opts...) return selector.NewSelector(opts...)

View File

@ -3,6 +3,7 @@ package roundrobin
import ( import (
"sync" "sync"
"github.com/micro/go-micro/cmd"
"github.com/micro/go-micro/registry" "github.com/micro/go-micro/registry"
"github.com/micro/go-micro/selector" "github.com/micro/go-micro/selector"
) )
@ -11,6 +12,10 @@ type roundRobinSelector struct {
so selector.Options so selector.Options
} }
func init() {
cmd.Selectors["roundrobin"] = NewSelector
}
func (r *roundRobinSelector) Select(service string, opts ...selector.SelectOption) (selector.Next, error) { func (r *roundRobinSelector) Select(service string, opts ...selector.SelectOption) (selector.Next, error) {
var sopts selector.SelectOptions var sopts selector.SelectOptions
for _, opt := range opts { for _, opt := range opts {
@ -68,7 +73,7 @@ func (r *roundRobinSelector) Close() error {
return nil return nil
} }
func NewRoundRobinSelector(opts ...selector.Option) selector.Selector { func NewSelector(opts ...selector.Option) selector.Selector {
var sopts selector.Options var sopts selector.Options
for _, opt := range opts { for _, opt := range opts {