hanahmily commented on code in PR #971: URL: https://github.com/apache/skywalking-banyandb/pull/971#discussion_r2793694045
########## banyand/metadata/embeddedserver/server.go: ########## Review Comment: The server boots up both etcd-based and property-based schema servers at all times. ########## banyand/metadata/schema/propertyserver/service.go: ########## @@ -0,0 +1,322 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package propertyserver implements a standalone gRPC server for schema property management. +package propertyserver + +import ( + "context" + "fmt" + "net" + "path" + "path/filepath" + "runtime/debug" + "strconv" + "sync" + "time" + + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery" + grpc_validator "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/validator" + "github.com/pkg/errors" + grpclib "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/health" + "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/status" + + "github.com/apache/skywalking-banyandb/api/common" + schemav1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/schema/v1" + "github.com/apache/skywalking-banyandb/banyand/internal/storage" + "github.com/apache/skywalking-banyandb/banyand/observability" + "github.com/apache/skywalking-banyandb/banyand/property/db" + "github.com/apache/skywalking-banyandb/pkg/fs" + "github.com/apache/skywalking-banyandb/pkg/logger" + "github.com/apache/skywalking-banyandb/pkg/run" + pkgtls "github.com/apache/skywalking-banyandb/pkg/tls" +) + +const ( + schemaGroup = "_schema" + defaultShardID = common.ShardID(0) + defaultRecvSize = 10 << 20 +) + +var ( + _ run.PreRunner = (*server)(nil) + _ run.Config = (*server)(nil) + _ run.Service = (*server)(nil) +) + +// Server is the interface for the standalone property server. +type Server interface { + run.PreRunner + run.Config + run.Service + GetPort() *uint32 +} + +type server struct { + db db.Database + lfs fs.FileSystem + omr observability.MetricsRegistry + closer *run.Closer + l *logger.Logger + ser *grpclib.Server + tlsReloader *pkgtls.Reloader + schemaService *schemaManagementServer + updateService *schemaUpdateServer + host string + certFile string + root string + keyFile string + addr string + repairBuildTreeCron string + minFileSnapshotAge time.Duration + flushTimeout time.Duration + snapshotSeq uint64 + expireTimeout time.Duration + repairQuickBuildTreeTime time.Duration + maxRecvMsgSize run.Bytes + maxFileSnapshotNum int + repairTreeSlotCount int + snapshotMu sync.Mutex + port uint32 + tls bool +} + +// NewServer returns a new standalone property server. +func NewServer(omr observability.MetricsRegistry) Server { + return &server{ + omr: omr, + closer: run.NewCloser(0), + } +} + +// GetPort returns the gRPC server port. +func (s *server) GetPort() *uint32 { + return &s.port +} + +func (s *server) Name() string { + return "property-server" +} + +func (s *server) FlagSet() *run.FlagSet { + flagS := run.NewFlagSet("schema-property-server") Review Comment: ```suggestion flagS := run.NewFlagSet("schema-server") ``` ########## banyand/metadata/schema/propertyserver/service.go: ########## @@ -0,0 +1,322 @@ +// Licensed to Apache Software Foundation (ASF) under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Apache Software Foundation (ASF) licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Package propertyserver implements a standalone gRPC server for schema property management. +package propertyserver + +import ( + "context" + "fmt" + "net" + "path" + "path/filepath" + "runtime/debug" + "strconv" + "sync" + "time" + + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/recovery" + grpc_validator "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/validator" + "github.com/pkg/errors" + grpclib "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/health" + "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/status" + + "github.com/apache/skywalking-banyandb/api/common" + schemav1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/schema/v1" + "github.com/apache/skywalking-banyandb/banyand/internal/storage" + "github.com/apache/skywalking-banyandb/banyand/observability" + "github.com/apache/skywalking-banyandb/banyand/property/db" + "github.com/apache/skywalking-banyandb/pkg/fs" + "github.com/apache/skywalking-banyandb/pkg/logger" + "github.com/apache/skywalking-banyandb/pkg/run" + pkgtls "github.com/apache/skywalking-banyandb/pkg/tls" +) + +const ( + schemaGroup = "_schema" + defaultShardID = common.ShardID(0) + defaultRecvSize = 10 << 20 +) + +var ( + _ run.PreRunner = (*server)(nil) + _ run.Config = (*server)(nil) + _ run.Service = (*server)(nil) +) + +// Server is the interface for the standalone property server. +type Server interface { + run.PreRunner + run.Config + run.Service + GetPort() *uint32 +} + +type server struct { + db db.Database + lfs fs.FileSystem + omr observability.MetricsRegistry + closer *run.Closer + l *logger.Logger + ser *grpclib.Server + tlsReloader *pkgtls.Reloader + schemaService *schemaManagementServer + updateService *schemaUpdateServer + host string + certFile string + root string + keyFile string + addr string + repairBuildTreeCron string + minFileSnapshotAge time.Duration + flushTimeout time.Duration + snapshotSeq uint64 + expireTimeout time.Duration + repairQuickBuildTreeTime time.Duration + maxRecvMsgSize run.Bytes + maxFileSnapshotNum int + repairTreeSlotCount int + snapshotMu sync.Mutex + port uint32 + tls bool +} + +// NewServer returns a new standalone property server. +func NewServer(omr observability.MetricsRegistry) Server { + return &server{ + omr: omr, + closer: run.NewCloser(0), + } +} + +// GetPort returns the gRPC server port. +func (s *server) GetPort() *uint32 { + return &s.port +} + +func (s *server) Name() string { + return "property-server" +} + +func (s *server) FlagSet() *run.FlagSet { + flagS := run.NewFlagSet("schema-property-server") Review Comment: Use "schema-server" for all configs and pkg name. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
