forked from TrueCloudLab/frostfs-sdk-go
[#210] subnet: Refactor and document package functionality
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
6709b00c89
commit
eb3b990812
13 changed files with 276 additions and 216 deletions
|
@ -36,13 +36,31 @@ func (p *PlacementPolicy) ToV2() *netmap.PlacementPolicy {
|
|||
|
||||
// SubnetID returns subnet to select nodes from.
|
||||
func (p *PlacementPolicy) SubnetID() *subnetid.ID {
|
||||
return (*subnetid.ID)(
|
||||
(*netmap.PlacementPolicy)(p).GetSubnetID())
|
||||
idv2 := (*netmap.PlacementPolicy)(p).GetSubnetID()
|
||||
if idv2 == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var id subnetid.ID
|
||||
|
||||
err := id.ReadFromV2(*idv2)
|
||||
if err != nil {
|
||||
panic(err) // will disappear after netmap package refactor
|
||||
}
|
||||
|
||||
return &id
|
||||
}
|
||||
|
||||
// SetSubnetID sets subnet to select nodes from.
|
||||
func (p *PlacementPolicy) SetSubnetID(subnet *subnetid.ID) {
|
||||
(*netmap.PlacementPolicy)(p).SetSubnetID((*refs.SubnetID)(subnet))
|
||||
var idv2 *refs.SubnetID
|
||||
|
||||
if subnet != nil {
|
||||
idv2 = new(refs.SubnetID)
|
||||
subnet.WriteToV2(idv2)
|
||||
}
|
||||
|
||||
(*netmap.PlacementPolicy)(p).SetSubnetID(idv2)
|
||||
}
|
||||
|
||||
// Replicas returns list of object replica descriptors.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue