Skip to content

Commit f55e3e4

Browse files
authored
Support node query gRPC service in lifecycle service (#956)
1 parent 5e585bc commit f55e3e4

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to Apache Software Foundation (ASF) under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Apache Software Foundation (ASF) licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package lifecycle
19+
20+
import (
21+
"context"
22+
23+
databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
24+
)
25+
26+
func (l *lifecycleService) GetCurrentNode(_ context.Context, _ *databasev1.GetCurrentNodeRequest) (*databasev1.GetCurrentNodeResponse, error) {
27+
return &databasev1.GetCurrentNodeResponse{
28+
Node: l.currentNode,
29+
}, nil
30+
}

banyand/backup/lifecycle/service.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"google.golang.org/grpc/credentials/insecure"
4242
"google.golang.org/grpc/health"
4343
"google.golang.org/grpc/health/grpc_health_v1"
44+
"google.golang.org/protobuf/types/known/timestamppb"
4445

4546
"github.com/apache/skywalking-banyandb/api/common"
4647
commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1"
@@ -70,6 +71,7 @@ var _ service = (*lifecycleService)(nil)
7071

7172
type lifecycleService struct {
7273
databasev1.UnimplementedClusterStateServiceServer
74+
databasev1.UnimplementedNodeQueryServiceServer
7375
metadata metadata.Repo
7476
omr observability.MetricsRegistry
7577
pm protector.Memory
@@ -79,6 +81,7 @@ type lifecycleService struct {
7981
grpcServer *grpclib.Server
8082
httpSrv *http.Server
8183
tlsReloader *pkgtls.Reloader
84+
currentNode *databasev1.Node
8285
clientCloser context.CancelFunc
8386
stopCh chan struct{}
8487
measureRoot string
@@ -165,6 +168,16 @@ func (l *lifecycleService) Validate() error {
165168
return errors.New("missing key file when TLS is enabled")
166169
}
167170
}
171+
l.currentNode = &databasev1.Node{
172+
Metadata: &commonv1.Metadata{
173+
Name: l.lifecycleGRPCAddr,
174+
},
175+
GrpcAddress: l.lifecycleGRPCAddr,
176+
HttpAddress: l.lifecycleHTTPAddr,
177+
Roles: make([]databasev1.Role, 0),
178+
Labels: common.ParseNodeFlags(),
179+
CreatedAt: timestamppb.Now(),
180+
}
168181
}
169182
return nil
170183
}
@@ -309,6 +322,7 @@ func (l *lifecycleService) startServers() {
309322

310323
l.grpcServer = grpclib.NewServer(opts...)
311324
databasev1.RegisterClusterStateServiceServer(l.grpcServer, l)
325+
databasev1.RegisterNodeQueryServiceServer(l.grpcServer, l)
312326
grpc_health_v1.RegisterHealthServer(l.grpcServer, health.NewServer())
313327

314328
// Setup HTTP server

0 commit comments

Comments
 (0)