selector: new selector interface with random & roundrobin implementation (#1761)
* selector: implement new selector interface plus random & roundrobin implementations * selector/roundrobin: remove unused consts * router: add close method to interface * selector/roundrobin: fix concurrent map iteration and map write * selector: replace variadic argument on Select
This commit is contained in:
10
selector/random/random.go
Normal file
10
selector/random/random.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package random
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/v2/selector"
|
||||
)
|
||||
|
||||
// NewSelector returns a random selector
|
||||
func NewSelector(opts ...selector.Option) selector.Selector {
|
||||
return selector.DefaultSelector
|
||||
}
|
||||
11
selector/random/random_test.go
Normal file
11
selector/random/random_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package random
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v2/selector"
|
||||
)
|
||||
|
||||
func TestRandom(t *testing.T) {
|
||||
selector.Tests(t, NewSelector())
|
||||
}
|
||||
Reference in New Issue
Block a user