frostfs-node/pkg/core/netmap/nodes.go
Evgenii Stratonikov 2d1232ce6d
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m25s
Build / Build Components (push) Successful in 1m57s
Pre-commit hooks / Pre-commit (push) Successful in 1m58s
Tests and linters / Run gofumpt (push) Successful in 3m50s
Tests and linters / Staticcheck (push) Successful in 4m21s
Tests and linters / Lint (push) Successful in 4m25s
Tests and linters / gopls check (push) Successful in 4m27s
Tests and linters / Tests (push) Successful in 4m44s
OCI image / Build container images (push) Successful in 5m19s
Tests and linters / Tests with -race (push) Successful in 5m32s
[#1689] network,core/netmap: Replace Iterate*() functions with iterators
Change-Id: I4842a3160d74c56d99ea9465d4be2f0662080605
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2025-04-15 14:47:32 +00:00

50 lines
1.6 KiB
Go

package netmap
import (
"iter"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
)
// Node is a named type of netmap.NodeInfo which provides interface needed
// in the current repository. Node is expected to be used everywhere instead
// of direct usage of netmap.NodeInfo, so it represents a type mediator.
type Node netmap.NodeInfo
// PublicKey returns public key bound to the storage node.
//
// Return value MUST NOT be mutated, make a copy first.
func (x Node) PublicKey() []byte {
return (netmap.NodeInfo)(x).PublicKey()
}
// Addresses returns an iterator over all announced network addresses.
func (x Node) Addresses() iter.Seq[string] {
return (netmap.NodeInfo)(x).NetworkEndpoints()
}
// IterateAddresses iterates over all announced network addresses
// and passes them into f. Handler MUST NOT be nil.
// Deprecated: use [Node.Addresses] instead.
func (x Node) IterateAddresses(f func(string) bool) {
for s := range (netmap.NodeInfo)(x).NetworkEndpoints() {
if f(s) {
return
}
}
}
// NumberOfAddresses returns number of announced network addresses.
func (x Node) NumberOfAddresses() int {
return (netmap.NodeInfo)(x).NumberOfNetworkEndpoints()
}
// ExternalAddresses returns external addresses of a node.
func (x Node) ExternalAddresses() []string {
return (netmap.NodeInfo)(x).ExternalAddresses()
}
// Nodes is a named type of []netmap.NodeInfo which provides interface needed
// in the current repository. Nodes is expected to be used everywhere instead
// of direct usage of []netmap.NodeInfo, so it represents a type mediator.
type Nodes []netmap.NodeInfo