Skip to content

Commit 2927063

Browse files
committed
fix: startWithListener register etcd
1 parent 9985e47 commit 2927063

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

zrpc/internal/rpcpubserver.go

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package internal
22

33
import (
4+
"net"
45
"os"
56
"strings"
67

@@ -53,6 +54,14 @@ func (s keepAliveServer) Start(fn RegisterFn) error {
5354
return s.Server.Start(fn)
5455
}
5556

57+
func (s keepAliveServer) StartWithListener(listener net.Listener, fn RegisterFn) error {
58+
if err := s.registerEtcd(); err != nil {
59+
return err
60+
}
61+
62+
return s.Server.StartWithListener(listener, fn)
63+
}
64+
5665
func figureOutListenOn(listenOn string) string {
5766
fields := strings.Split(listenOn, ":")
5867
if len(fields) == 0 {

zrpc/internal/rpcpubserver_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func TestNewRpcPubServer(t *testing.T) {
1818
assert.NotPanics(t, func() {
1919
s.Start(nil)
2020
})
21+
22+
assert.NotPanics(t, func() {
23+
s.StartWithListener(nil, nil)
24+
})
2125
}
2226

2327
func TestFigureOutListenOn(t *testing.T) {

0 commit comments

Comments
 (0)