From 057d53459b6e060faa936e34d30d091fff6eebd5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 28 Apr 2022 10:19:26 +0300 Subject: [PATCH] [#1319] services/object: Remove `Write` method from `local` and `remote` targets They work with prepared objects only. Signed-off-by: Evgenii Stratonikov --- pkg/services/object/put/distributed.go | 7 ++++++- pkg/services/object/put/local.go | 10 ---------- pkg/services/object/put/remote.go | 2 -- pkg/services/object/put/streamer.go | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/services/object/put/distributed.go b/pkg/services/object/put/distributed.go index 9580cb273f..6f5933c297 100644 --- a/pkg/services/object/put/distributed.go +++ b/pkg/services/object/put/distributed.go @@ -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 diff --git a/pkg/services/object/put/local.go b/pkg/services/object/put/local.go index b4f04e6265..bff5aa388e 100644 --- a/pkg/services/object/put/local.go +++ b/pkg/services/object/put/local.go @@ -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) diff --git a/pkg/services/object/put/remote.go b/pkg/services/object/put/remote.go index 0d4ff40f52..1a9d964da9 100644 --- a/pkg/services/object/put/remote.go +++ b/pkg/services/object/put/remote.go @@ -13,8 +13,6 @@ import ( ) type remoteTarget struct { - transformer.ObjectTarget - ctx context.Context keyStorage *util.KeyStorage diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index 0b6764dbe9..fbef13616f 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -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,