Skip to content

Commit

Permalink
feat:support rls to push xds client
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun committed May 31, 2023
1 parent cea410f commit ef420f4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions apiserver/grpcserver/discover/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (g *GRPCServer) Run(errCh chan error) {
if config.Enable {
// 注册 v1 版本的 spec discover server
apiservice.RegisterPolarisGRPCServer(server, g.v1server)
apiservice.RegisterPolarisHeartbeatGRPCServer(server, g.v1server)
openMethod, getErr := apiserver.GetClientOpenMethod(config.Include, g.GetProtocol())
if getErr != nil {
return getErr
Expand Down
2 changes: 1 addition & 1 deletion apiserver/grpcserver/discover/v1/client_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (g *DiscoverServer) Heartbeat(ctx context.Context, in *apiservice.Instance)
}

// BatchHeartbeat 批量上报心跳
func (g *DiscoverServer) BatchHeartbeat(svr apiservice.PolarisGRPC_BatchHeartbeatServer) error {
func (g *DiscoverServer) BatchHeartbeat(svr apiservice.PolarisHeartbeatGRPC_BatchHeartbeatServer) error {
ctx := grpcserver.ConvertContext(svr.Context())

for {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ require (
require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/agiledragon/gomonkey/v2 v2.10.1
github.com/polarismesh/specification v1.3.2-alpha.2
github.com/polarismesh/specification v1.3.2-alpha.4
)

replace gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.2
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ github.com/polarismesh/go-restful-openapi/v2 v2.0.0-20220928152401-083908d10219
github.com/polarismesh/go-restful-openapi/v2 v2.0.0-20220928152401-083908d10219/go.mod h1:4WhwBysTom9Eoy0hQ4W69I0FmO+T0EpjEW9/5sgHoUk=
github.com/polarismesh/specification v1.3.2-alpha.2 h1:cMghyvCnRVM5ca2kYCGHOgIIxVnokiMvw0720q8a8RA=
github.com/polarismesh/specification v1.3.2-alpha.2/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU=
github.com/polarismesh/specification v1.3.2-alpha.4 h1:J5Qh1Ef1RKbuuD1UqKr6mfG1gXY4rSLL0DQQph2CJP8=
github.com/polarismesh/specification v1.3.2-alpha.4/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
Expand Down
8 changes: 4 additions & 4 deletions plugin/healthchecker/leader/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (p *RemotePeer) Serve(_ context.Context, checker *LeaderHealthChecker,
p.conns = append(p.conns, conn)
}
for i := 0; i < streamNum; i++ {
client := apiservice.NewPolarisGRPCClient(p.conns[i])
client := apiservice.NewPolarisHeartbeatGRPCClient(p.conns[i])
puter, err := client.BatchHeartbeat(ctx, grpc.Header(&metadata.MD{
sendResource: []string{utils.LocalHost},
}))
Expand Down Expand Up @@ -291,9 +291,9 @@ func (p *RemotePeer) DelFunc(req *apiservice.DelHeartbeatsRequest) {
}
}

func (p *RemotePeer) choseOneClient() apiservice.PolarisGRPCClient {
func (p *RemotePeer) choseOneClient() apiservice.PolarisHeartbeatGRPCClient {
index := rand.Intn(len(p.conns))
return apiservice.NewPolarisGRPCClient(p.conns[index])
return apiservice.NewPolarisHeartbeatGRPCClient(p.conns[index])
}

func (p *RemotePeer) Storage() BeatRecordCache {
Expand Down Expand Up @@ -341,7 +341,7 @@ type PeerReadTask struct {

type beatSender struct {
lock sync.RWMutex
sender apiservice.PolarisGRPC_BatchHeartbeatClient
sender apiservice.PolarisHeartbeatGRPC_BatchHeartbeatClient
}

func (s *beatSender) Send(req *apiservice.HeartbeatsRequest) error {
Expand Down
2 changes: 1 addition & 1 deletion plugin/healthchecker/leader/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (ms *MockPolarisGRPCServer) Heartbeat(context.Context,
}

// BatchHeartbeat 批量上报心跳
func (ms *MockPolarisGRPCServer) BatchHeartbeat(svr service_manage.PolarisGRPC_BatchHeartbeatServer) error {
func (ms *MockPolarisGRPCServer) BatchHeartbeat(svr service_manage.PolarisHeartbeatGRPC_BatchHeartbeatServer) error {
for {
req, err := svr.Recv()
if err != nil {
Expand Down

0 comments on commit ef420f4

Please sign in to comment.