fix: comments in neighbours function (#3069)

Signed-off-by: fcgxz2003 <834756128@qq.com>
Signed-off-by: XZ <834756128@qq.com>
This commit is contained in:
dlut_xz 2024-02-07 10:35:46 +08:00 committed by GitHub
parent bd57994f84
commit 3a05eb6fb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -328,8 +328,8 @@ func (nt *networkTopology) ProbedCount(hostID string) (uint64, error) {
return probedCount, nil return probedCount, nil
} }
// Neighbours gets the specified number neighbors of source host for aggregation, by regexp scaning cache // Neighbours gets the specified number neighbors of source host for aggregation by regexp scaning cache
// (if it is not enough for code to work, access redis to get neighbors), then parsing keys and loading host, // (if it is not enough for code to work, get neighbors from redis), then parsing keys and loading host,
// while updating the cache data. // while updating the cache data.
func (nt *networkTopology) Neighbours(srcHost *resource.Host, n int) ([]*resource.Host, error) { func (nt *networkTopology) Neighbours(srcHost *resource.Host, n int) ([]*resource.Host, error) {
ctx, cancel := context.WithTimeout(context.Background(), contextTimeout) ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
@ -340,7 +340,7 @@ func (nt *networkTopology) Neighbours(srcHost *resource.Host, n int) ([]*resourc
return nil, err return nil, err
} }
// If it is not enough for code to work, access redis to get neighbors. // If it is not enough for code to work, get neighbors from redis.
if len(networkTopologyKeys) < n { if len(networkTopologyKeys) < n {
networkTopologyKeys, _, err = nt.rdb.Scan(ctx, 0, pkgredis.MakeNetworkTopologyKeyInScheduler(srcHost.ID, "*"), defaultScanCountLimit).Result() networkTopologyKeys, _, err = nt.rdb.Scan(ctx, 0, pkgredis.MakeNetworkTopologyKeyInScheduler(srcHost.ID, "*"), defaultScanCountLimit).Result()
if err != nil { if err != nil {