Fine0830 commented on code in PR #918:
URL: 
https://github.com/apache/skywalking-banyandb/pull/918#discussion_r2652091651


##########
fodc/proxy/internal/registry/registry.go:
##########
@@ -0,0 +1,327 @@
+// 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 registry provides functionality for managing and tracking FODC 
agents.
+package registry
+
+import (
+       "context"
+       "fmt"
+       "sync"
+       "time"
+
+       "github.com/google/uuid"
+
+       "github.com/apache/skywalking-banyandb/pkg/logger"
+)
+
+// AgentStatus represents the current status of an agent.
+type AgentStatus string
+
+const (
+       // AgentStatusOnline indicates the agent is online and connected.
+       AgentStatusOnline AgentStatus = "online"
+       // AgentStatusOffline indicates the agent is offline or unconnected.
+       AgentStatusOffline AgentStatus = "unconnected"
+)
+
+// Address represents a network address.
+type Address struct {
+       IP   string
+       Port int
+}
+
+// AgentIdentity represents the identity of an agent.
+type AgentIdentity struct {
+       Labels map[string]string
+       IP     string
+       Role   string
+       Port   int
+}
+
+// AgentInfo contains information about a registered agent.
+type AgentInfo struct {
+       Labels         map[string]string
+       RegisteredAt   time.Time
+       LastHeartbeat  time.Time
+       AgentID        string
+       NodeRole       string
+       Status         AgentStatus
+       AgentIdentity  AgentIdentity
+       PrimaryAddress Address
+}
+
+// AgentRegistry manages the lifecycle and state of all connected FODC Agents.
+type AgentRegistry struct {
+       agents            map[string]*AgentInfo
+       logger            *logger.Logger
+       healthCheckTicker *time.Ticker
+       healthCheckStopCh chan struct{}
+       mu                sync.RWMutex
+       heartbeatTimeout  time.Duration
+       cleanupTimeout    time.Duration
+       maxAgents         int
+}
+
+// NewAgentRegistry creates a new AgentRegistry instance.
+func NewAgentRegistry(logger *logger.Logger, heartbeatTimeout, cleanupTimeout 
time.Duration, maxAgents int) *AgentRegistry {
+       ar := &AgentRegistry{
+               agents:            make(map[string]*AgentInfo),
+               logger:            logger,
+               heartbeatTimeout:  heartbeatTimeout,
+               maxAgents:         maxAgents,
+               cleanupTimeout:    cleanupTimeout,
+               healthCheckStopCh: make(chan struct{}),
+       }
+       ar.startHealthCheck()
+       return ar
+}
+
+// RegisterAgent registers a new agent or updates existing agent information.
+func (ar *AgentRegistry) RegisterAgent(_ context.Context, identity 
AgentIdentity, primaryAddr Address) (string, error) {

Review Comment:
   Maximum agents: Configurable (default limit enforced)
   Primary address IP: Cannot be empty
   Primary address port: Must be > 0
   Node role: Cannot be empty
   Agent ID: Auto-generated UUID on successful registration



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