forked from TrueCloudLab/frostfs-node
[#607] network: Do not work with Address pointers
`network.Address` structure in most cases created once and used read-only. Replace `AddressFromString` function with `Address.FromString` method with the same purpose and implementation. Make all libraries to work with value. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5de074f24c
commit
adbbad0beb
35 changed files with 128 additions and 97 deletions
|
@ -205,7 +205,7 @@ type remoteLoadAnnounceProvider struct {
|
|||
loadAddrSrc network.LocalAddressSource
|
||||
|
||||
clientCache interface {
|
||||
Get(*network.Address) (apiClient.Client, error)
|
||||
Get(network.Address) (apiClient.Client, error)
|
||||
}
|
||||
|
||||
deadEndProvider loadcontroller.WriterProvider
|
||||
|
@ -218,12 +218,14 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
|
|||
|
||||
addr := srv.Address()
|
||||
|
||||
netAddr, err := network.AddressFromString(addr)
|
||||
var netAddr network.Address
|
||||
|
||||
err := netAddr.FromString(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not convert address to IP format: %w", err)
|
||||
}
|
||||
|
||||
if network.IsLocalAddress(r.loadAddrSrc, *netAddr) {
|
||||
if network.IsLocalAddress(r.loadAddrSrc, netAddr) {
|
||||
// if local => return no-op writer
|
||||
return loadcontroller.SimpleWriterProvider(new(nopLoadWriter)), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue