Skip to content

Commit

Permalink
fix: startWithListener register etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
meizzliu authored and winteriscome committed Dec 17, 2024
1 parent 26450b7 commit 022b53b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zrpc/internal/rpcpubserver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal

import (
"net"
"os"
"strings"

Expand Down Expand Up @@ -53,6 +54,14 @@ func (s keepAliveServer) Start(fn RegisterFn) error {
return s.Server.Start(fn)
}

func (s keepAliveServer) StartWithListener(listener net.Listener, fn RegisterFn) error {
if err := s.registerEtcd(); err != nil {
return err
}

return s.Server.StartWithListener(listener, fn)
}

func figureOutListenOn(listenOn string) string {
fields := strings.Split(listenOn, ":")
if len(fields) == 0 {
Expand Down
4 changes: 4 additions & 0 deletions zrpc/internal/rpcpubserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func TestNewRpcPubServer(t *testing.T) {
assert.NotPanics(t, func() {
s.Start(nil)
})

assert.NotPanics(t, func() {
s.StartWithListener(nil, nil)
})
}

func TestFigureOutListenOn(t *testing.T) {
Expand Down

0 comments on commit 022b53b

Please sign in to comment.