Skip to content

Commit

Permalink
slicer: Extend slicer.Options with copies number
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Aug 3, 2023
1 parent 707fbe7 commit b7b2858
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/object_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ type PrmObjectPutInit struct {
copyNum uint32
}

// SetCopiesNumber sets number of object copies that is enough to consider put successful.
// SetCopiesNumber sets the minimal number of copies (out of the number specified by container placement policy) for
// the object PUT operation to succeed. This means that object operation will return with successful status even before
// container placement policy is completely satisfied.
func (x *PrmObjectPutInit) SetCopiesNumber(copiesNumber uint32) {
x.copyNum = copiesNumber
}
Expand Down
14 changes: 14 additions & 0 deletions object/slicer/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Options struct {

withHomoChecksum bool

copiesNumber uint32

sessionToken *session.Object
bearerToken *bearer.Token
}
Expand Down Expand Up @@ -45,6 +47,13 @@ func (x *Options) SetBearerToken(bearerToken *bearer.Token) {
x.bearerToken = bearerToken
}

// SetCopiesNumber sets the minimal number of copies (out of the number specified by container placement policy) for
// the object PUT operation to succeed. This means that object operation will return with successful status even before
// container placement policy is completely satisfied.
func (x *Options) SetCopiesNumber(copiesNumber uint32) {
x.copiesNumber = copiesNumber
}

// ObjectPayloadLimit returns required max object size.
func (x *Options) ObjectPayloadLimit() uint64 {
return x.objectPayloadLimit
Expand All @@ -69,3 +78,8 @@ func (x *Options) Session() *session.Object {
func (x *Options) BearerToken() *bearer.Token {
return x.bearerToken
}

// CopiesNumber returns the number of object copies.
func (x *Options) CopiesNumber() uint32 {
return x.copiesNumber
}
1 change: 1 addition & 0 deletions object/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func initPayloadStream(ctx context.Context, ow ObjectWriter, header object.Objec
}

var prm client.PrmObjectPutInit
prm.SetCopiesNumber(opts.copiesNumber)

if opts.sessionToken != nil {
prm.WithinSession(*opts.sessionToken)
Expand Down

0 comments on commit b7b2858

Please sign in to comment.