mirror of
https://github.com/smallnest/rpcx.git
synced 2025-10-24 08:33:07 +08:00
add server plugins feature and add zookeeper/etcd/consul registries
This commit is contained in:
38
serverplugin/etcd_test.go
Normal file
38
serverplugin/etcd_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// +build etcd
|
||||
|
||||
package serverplugin
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
metrics "github.com/rcrowley/go-metrics"
|
||||
"github.com/smallnest/rpcx/server"
|
||||
)
|
||||
|
||||
func TestEtcdRegistry(t *testing.T) {
|
||||
s := &server.Server{}
|
||||
|
||||
r := &EtcdRegisterPlugin{
|
||||
ServiceAddress: "tcp@127.0.0.1:8972",
|
||||
EtcdServers: []string{"127.0.0.1:2379"},
|
||||
BasePath: "/rpcx_test",
|
||||
Metrics: metrics.NewRegistry(),
|
||||
Services: make([]string, 1),
|
||||
UpdateInterval: time.Minute,
|
||||
}
|
||||
err := r.Start()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.Plugins.Add(r)
|
||||
|
||||
s.RegisterName("Arith", new(Arith), "")
|
||||
go s.Serve("tcp", "127.0.0.1:8972")
|
||||
defer s.Close()
|
||||
|
||||
if len(r.Services) != 1 {
|
||||
t.Fatal("failed to register services in etcd")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user