[#1319] services/object: Remove Write
method from local
and remote
targets
They work with prepared objects only. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4ea03c01b5
commit
057d53459b
4 changed files with 7 additions and 14 deletions
|
@ -15,6 +15,11 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type preparedObjectTarget interface {
|
||||
WriteHeader(*objectSDK.Object) error
|
||||
Close() (*transformer.AccessIdentifiers, error)
|
||||
}
|
||||
|
||||
type distributedTarget struct {
|
||||
traversal traversal
|
||||
|
||||
|
@ -24,7 +29,7 @@ type distributedTarget struct {
|
|||
|
||||
payload []byte
|
||||
|
||||
nodeTargetInitializer func(nodeDesc) transformer.ObjectTarget
|
||||
nodeTargetInitializer func(nodeDesc) preparedObjectTarget
|
||||
|
||||
isLocalKey func([]byte) bool
|
||||
|
||||
|
|
|
@ -19,24 +19,14 @@ type localTarget struct {
|
|||
storage ObjectStorage
|
||||
|
||||
obj *object.Object
|
||||
|
||||
payload []byte
|
||||
}
|
||||
|
||||
func (t *localTarget) WriteHeader(obj *object.Object) error {
|
||||
t.obj = obj
|
||||
|
||||
t.payload = make([]byte, 0, obj.PayloadSize())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *localTarget) Write(p []byte) (n int, err error) {
|
||||
t.payload = append(t.payload, p...)
|
||||
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (t *localTarget) Close() (*transformer.AccessIdentifiers, error) {
|
||||
if err := t.storage.Put(t.obj); err != nil {
|
||||
return nil, fmt.Errorf("(%T) could not put object to local storage: %w", t, err)
|
||||
|
|
|
@ -13,8 +13,6 @@ import (
|
|||
)
|
||||
|
||||
type remoteTarget struct {
|
||||
transformer.ObjectTarget
|
||||
|
||||
ctx context.Context
|
||||
|
||||
keyStorage *util.KeyStorage
|
||||
|
|
|
@ -184,7 +184,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget {
|
|||
},
|
||||
remotePool: p.remotePool,
|
||||
localPool: p.localPool,
|
||||
nodeTargetInitializer: func(node nodeDesc) transformer.ObjectTarget {
|
||||
nodeTargetInitializer: func(node nodeDesc) preparedObjectTarget {
|
||||
if node.local {
|
||||
return &localTarget{
|
||||
storage: p.localStore,
|
||||
|
|
Loading…
Reference in a new issue