Merge branch 'release/0.2.1'
This commit is contained in:
commit
d27583245e
4 changed files with 12 additions and 44 deletions
|
@ -1,6 +1,12 @@
|
|||
# Changelog
|
||||
This is the changelog for NeoFS Proto
|
||||
|
||||
## [0.2.1] - 2019-11-22
|
||||
|
||||
### Changed
|
||||
- Removed SendPutRequest
|
||||
- MakePutRequestHeader sets only object and token
|
||||
|
||||
## [0.2.0] - 2019-11-21
|
||||
|
||||
### Added
|
||||
|
@ -20,3 +26,4 @@ This is the changelog for NeoFS Proto
|
|||
Initial public release
|
||||
|
||||
[0.2.0]: https://github.com/nspcc-dev/neofs-proto/compare/v0.1.0...v0.2.0
|
||||
[0.2.1]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.0...v0.2.1
|
||||
|
|
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ require (
|
|||
github.com/golang/protobuf v1.3.2
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/mr-tron/base58 v1.1.2
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.1
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.2
|
||||
github.com/nspcc-dev/netmap v1.6.1
|
||||
github.com/nspcc-dev/tzhash v1.3.0
|
||||
github.com/onsi/ginkgo v1.10.2 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -71,8 +71,8 @@ github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjW
|
|||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nspcc-dev/hrw v1.0.8 h1:vwRuJXZXgkMvf473vFzeWGCfY1WBVeSHAEHvR4u3/Cg=
|
||||
github.com/nspcc-dev/hrw v1.0.8/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.1 h1:NxKexcW88vlHO/u7EYjx5Q1UaOQ7XhYrCsLSVgOcCxw=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.1/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.2 h1:jLc5O+Wdpaq7L4lNYFX7li+OP4I1FsvvcPW1NXm3erY=
|
||||
github.com/nspcc-dev/neofs-crypto v0.2.2/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||
github.com/nspcc-dev/netmap v1.6.1 h1:Pigqpqi6QSdRiusbq5XlO20A18k6Eyu7j9MzOfAE3CM=
|
||||
github.com/nspcc-dev/netmap v1.6.1/go.mod h1:mhV3UOg9ljQmu0teQShD6+JYX09XY5gu2I4hIByCH9M=
|
||||
github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c=
|
||||
|
|
|
@ -4,53 +4,14 @@ import (
|
|||
"io"
|
||||
|
||||
"code.cloudfoundry.org/bytefmt"
|
||||
"github.com/nspcc-dev/neofs-proto/service"
|
||||
"github.com/nspcc-dev/neofs-proto/session"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const maxGetPayloadSize = 3584 * 1024 // 3.5 MiB
|
||||
|
||||
func splitBytes(data []byte, maxSize int) (result [][]byte) {
|
||||
l := len(data)
|
||||
if l == 0 {
|
||||
return [][]byte{data}
|
||||
}
|
||||
for i := 0; i < l; i += maxSize {
|
||||
last := i + maxSize
|
||||
if last > l {
|
||||
last = l
|
||||
}
|
||||
result = append(result, data[i:last])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SendPutRequest prepares object and sends it in chunks through protobuf stream.
|
||||
func SendPutRequest(s Service_PutClient, obj *Object, epoch uint64, ttl uint32) (*PutResponse, error) {
|
||||
// TODO split must take into account size of the marshalled Object
|
||||
chunks := splitBytes(obj.Payload, maxGetPayloadSize)
|
||||
obj.Payload = chunks[0]
|
||||
if err := s.Send(MakePutRequestHeader(obj, epoch, ttl, nil)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i := range chunks[1:] {
|
||||
if err := s.Send(MakePutRequestChunk(chunks[i+1])); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
resp, err := s.CloseAndRecv()
|
||||
if err != nil && err != io.EOF {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// MakePutRequestHeader combines object, epoch, ttl and session token value
|
||||
// MakePutRequestHeader combines object and session token value
|
||||
// into header of object put request.
|
||||
func MakePutRequestHeader(obj *Object, epoch uint64, ttl uint32, token *session.Token) *PutRequest {
|
||||
func MakePutRequestHeader(obj *Object, token *session.Token) *PutRequest {
|
||||
return &PutRequest{
|
||||
RequestMetaHeader: service.RequestMetaHeader{TTL: ttl, Epoch: epoch},
|
||||
R: &PutRequest_Header{Header: &PutRequest_PutHeader{
|
||||
Object: obj,
|
||||
Token: token,
|
||||
|
|
Loading…
Reference in a new issue