mrproliu commented on code in PR #920:
URL: 
https://github.com/apache/skywalking-banyandb/pull/920#discussion_r2659314170


##########
banyand/metadata/dns/dns.go:
##########
@@ -0,0 +1,508 @@
+// 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 dns implements DNS-based node discovery for distributed metadata 
management.
+package dns
+
+import (
+       "context"
+       "errors"
+       "fmt"
+       "net"
+       "sync"
+       "time"
+
+       "google.golang.org/grpc"
+       "google.golang.org/grpc/credentials"
+       "google.golang.org/grpc/credentials/insecure"
+
+       databasev1 
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+       "github.com/apache/skywalking-banyandb/banyand/metadata/schema"
+       "github.com/apache/skywalking-banyandb/banyand/observability"
+       "github.com/apache/skywalking-banyandb/pkg/grpchelper"
+       "github.com/apache/skywalking-banyandb/pkg/logger"
+       "github.com/apache/skywalking-banyandb/pkg/run"
+       pkgtls "github.com/apache/skywalking-banyandb/pkg/tls"
+)
+
+// Service implements DNS-based node discovery.
+type Service struct {
+       lastQueryTime     time.Time
+       resolver          Resolver
+       caCertReloader    *pkgtls.Reloader
+       nodeCache         map[string]*databasev1.Node
+       closer            *run.Closer
+       log               *logger.Logger
+       metrics           *metrics
+       handlers          map[string]schema.EventHandler
+       caCertPath        string
+       srvAddresses      []string
+       lastSuccessfulDNS []string
+       pollInterval      time.Duration
+       initInterval      time.Duration
+       initDuration      time.Duration
+       grpcTimeout       time.Duration
+       cacheMutex        sync.RWMutex
+       lastSuccessMutex  sync.RWMutex
+       handlersMutex     sync.RWMutex
+       lastQueryMutex    sync.RWMutex
+       tlsEnabled        bool
+}
+
+// Config holds configuration for DNS discovery service.
+type Config struct {
+       CACertPath   string
+       SRVAddresses []string
+       InitInterval time.Duration
+       InitDuration time.Duration
+       PollInterval time.Duration
+       GRPCTimeout  time.Duration
+       TLSEnabled   bool
+}
+
+// Resolver defines the interface for DNS SRV lookups.
+type Resolver interface {
+       LookupSRV(ctx context.Context, name string) (string, []*net.SRV, error)

Review Comment:
   Because the UT still needs to mock the DNS result, this interface is 
necessary. 



-- 
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]

Reply via email to