register and deregister

This commit is contained in:
Asim Aslam 2019-01-24 13:58:56 +00:00 committed by Vasiliy Tolstov
parent 88911744b5
commit 00b9b850c6
2 changed files with 6 additions and 17 deletions

View File

@ -246,12 +246,18 @@ func (h *httpServer) Start() error {
return errors.New("Server required http.Handler")
}
// register
h.Register()
go http.Serve(ln, handler)
go func() {
ch := <-h.exit
ch <- ln.Close()
// deregister
h.Deregister()
opts.Broker.Disconnect()
}()

View File

@ -6,7 +6,6 @@ import (
"net/http"
"testing"
"github.com/micro/go-micro/registry"
"github.com/micro/go-micro/registry/memory"
"github.com/micro/go-micro/server"
)
@ -36,11 +35,6 @@ func TestHTTPServer(t *testing.T) {
t.Fatal(err)
}
// register server
if err := srv.Register(); err != nil {
t.Fatal(err)
}
// lookup server
service, err := reg.GetService(server.DefaultName)
if err != nil {
@ -71,17 +65,6 @@ func TestHTTPServer(t *testing.T) {
t.Fatalf("Expected response %s, got %s", "hello world", s)
}
// deregister server
if err := srv.Deregister(); err != nil {
t.Fatal(err)
}
// try get service
service, err = reg.GetService(server.DefaultName)
if err == nil {
t.Fatalf("Expected %v got %+v", registry.ErrNotFound, service)
}
// stop server
if err := srv.Stop(); err != nil {
t.Fatal(err)