mirror of
				https://github.com/smallnest/rpcx.git
				synced 2025-11-01 03:42:38 +08:00 
			
		
		
		
	add server plugins feature and add zookeeper/etcd/consul registries
This commit is contained in:
		
							
								
								
									
										38
									
								
								serverplugin/consul_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								serverplugin/consul_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| // +build consul | ||||
|  | ||||
| package serverplugin | ||||
|  | ||||
| import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	metrics "github.com/rcrowley/go-metrics" | ||||
| 	"github.com/smallnest/rpcx/server" | ||||
| ) | ||||
|  | ||||
| func TestConsulRegistry(t *testing.T) { | ||||
| 	s := &server.Server{} | ||||
|  | ||||
| 	r := &ConsulRegisterPlugin{ | ||||
| 		ServiceAddress: "tcp@127.0.0.1:8972", | ||||
| 		ConsulServers:  []string{"127.0.0.1:8500"}, | ||||
| 		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 consul") | ||||
| 	} | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 smallnest
					smallnest