Skip to content

Commit

Permalink
pkg/core: Separate HeaderWriter from object.Target interface
Browse files Browse the repository at this point in the history
Also, reuse it in the get service.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Dec 7, 2023
1 parent 91f43bb commit 671038c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
9 changes: 7 additions & 2 deletions pkg/core/object/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)

// Target is an interface of the object writer.
type Target interface {
// HeaderWriter is an interface of target component
// to write object header.
type HeaderWriter interface {
// WriteHeader writes object header w/ payload part.
// The payload of the object may be incomplete.
//
Expand All @@ -18,7 +19,11 @@ type Target interface {
//
// Must not be called after Close call.
WriteHeader(*object.Object) error
}

// Target is an interface of the object writer.
type Target interface {
HeaderWriter
// Write writes object payload chunk.
//
// Can be called multiple times.
Expand Down
11 changes: 3 additions & 8 deletions pkg/services/object/get/prm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"hash"

coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
objectcore "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/services/object/util"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
Expand Down Expand Up @@ -93,15 +94,9 @@ type ChunkWriter interface {
WriteChunk([]byte) error
}

// HeaderWriter is an interface of target component
// to write object header.
type HeaderWriter interface {
WriteHeader(*object.Object) error
}

// ObjectWriter is an interface of target component to write object.
type ObjectWriter interface {
HeaderWriter
objectcore.HeaderWriter
ChunkWriter
}

Expand Down Expand Up @@ -166,7 +161,7 @@ func (p *commonPrm) WithCachedSignerKey(signerKey *ecdsa.PrivateKey) {
}

// SetHeaderWriter sets target component to write the object header.
func (p *HeadPrm) SetHeaderWriter(w HeaderWriter) {
func (p *HeadPrm) SetHeaderWriter(w objectcore.HeaderWriter) {
p.objWriter = &partWriter{
headWriter: w,
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/services/object/get/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
objectcore "github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
internal "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
internalclient "github.com/nspcc-dev/neofs-node/pkg/services/object/internal/client"
Expand Down Expand Up @@ -35,7 +36,7 @@ type storageEngineWrapper struct {
type partWriter struct {
ObjectWriter

headWriter HeaderWriter
headWriter objectcore.HeaderWriter

chunkWriter ChunkWriter
}
Expand Down

0 comments on commit 671038c

Please sign in to comment.