Copilot commented on code in PR #678:
URL: https://github.com/apache/dubbo-go-pixiu/pull/678#discussion_r2098079245


##########
pkg/server/cluster_manager.go:
##########
@@ -215,17 +218,48 @@ func (cm *ClusterManager) HasCluster(clusterName string) 
bool {
 }
 
 func (s *ClusterStore) AddCluster(c *model.ClusterConfig) {
+       atomic.SwapInt32(&endpointIndex, 1)
+
        if c.Name == "" {
                index := atomic.AddInt32(&clusterIndex, 1)
                c.Name = fmt.Sprintf("cluster%d", index)
        }
+
+       s.AssembleLLMCLusterEndpoints(c)
+
        s.Config = append(s.Config, c)
        s.clustersMap[c.Name] = cluster.NewCluster(c)
        c.CreateConsistentHash()
 }
 
-func (s *ClusterStore) UpdateCluster(new *model.ClusterConfig) {
+func (s *ClusterStore) AssembleLLMCLusterEndpoints(c *model.ClusterConfig) {
+       if c == nil {
+               return
+       }
+
+       for _, endpoint := range c.Endpoints {
+               // not a llm endpoint
+               if endpoint.LLMMeta == nil {
+                       continue
+               }
+
+               if endpoint.LLMMeta.Name == "" {
+                       index := atomic.AddInt32(&endpointIndex, 1)
+                       endpoint.LLMMeta.Name = fmt.Sprintf("%s-%d", 
endpoint.LLMMeta.Provider, index)
+               }
 
+               if endpoint.Address.Address == "0.0.0.0" && 
endpoint.Address.Domains == nil {

Review Comment:
   [nitpick] Consider extracting the hardcoded string "0.0.0.0" into a named 
constant to improve readability and maintainability.
   ```suggestion
                if endpoint.Address.Address == DefaultIPAddress && 
endpoint.Address.Domains == nil {
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to