[#537] Upgrade NeoFS SDK Go with changed netmap package

`PlacementPolicy` type now provides methods to work with QL-encoded
policies. System network parameters can be read using dedicated method
without iterating. Applications can work with `PlacementPolicy`
variables directly so there is no need to use pointers.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-15 22:31:41 +03:00 committed by Alex Vanin
parent cfe7591cf7
commit f0749fd23e
10 changed files with 43 additions and 76 deletions

View file

@ -24,7 +24,7 @@ type (
// Config contains data which handler needs to keep.
Config struct {
DefaultPolicy *netmap.PlacementPolicy
DefaultPolicy netmap.PlacementPolicy
DefaultMaxAge int
NotificatorEnabled bool
}

View file

@ -623,16 +623,18 @@ func (h *handler) CreateBucketHandler(w http.ResponseWriter, r *http.Request) {
return
}
useDefaultPolicy := true
if createParams.LocationConstraint != "" {
for _, placementPolicy := range policies {
if placementPolicy.LocationConstraint == createParams.LocationConstraint {
p.Policy = placementPolicy.Policy
p.LocationConstraint = createParams.LocationConstraint
useDefaultPolicy = false
break
}
}
}
if p.Policy == nil {
if useDefaultPolicy {
p.Policy = h.cfg.DefaultPolicy
}

View file

@ -145,7 +145,7 @@ func (n *layer) createContainer(ctx context.Context, p *CreateBucketParams) (*da
idCnr, err := n.neoFS.CreateContainer(ctx, PrmContainerCreate{
Creator: bktInfo.Owner,
Policy: *p.Policy,
Policy: p.Policy,
Name: p.Name,
SessionToken: p.SessionToken,
AdditionalAttributes: attributes,

View file

@ -136,7 +136,7 @@ type (
// CreateBucketParams stores bucket create request parameters.
CreateBucketParams struct {
Name string
Policy *netmap.PlacementPolicy
Policy netmap.PlacementPolicy
EACL *eacl.Table
SessionToken *session.Container
LocationConstraint string