frostfs-sdk-go/object/transformer/types.go

63 lines
1.8 KiB
Go

package transformer
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
)
// AccessIdentifiers represents group of the object identifiers
// that are returned after writing the object.
// Consists of the ID of the stored object and the ID of the parent object.
type AccessIdentifiers struct {
ParentID *oid.ID
SelfID oid.ID
ParentHeader *object.Object
}
// EpochSource is a source for the current epoch.
type EpochSource interface {
CurrentEpoch() uint64
}
// ChunkedObjectWriter is an interface of the object writer
// that writes object chunked.
type ChunkedObjectWriter interface {
// WriteHeader writes object header w/ payload part.
// The payload of the object may be incomplete.
//
// Must be called exactly once. Control remains with the caller.
// Missing a call or re-calling can lead to undefined behavior
// that depends on the implementation.
//
// Must not be called after Close call.
WriteHeader(context.Context, *object.Object) error
// Write writes object payload chunk.
//
// Can be called multiple times.
//
// Must not be called after Close call.
Write(context.Context, []byte) (int, error)
// Close is used to finish object writing.
//
// Close must return access identifiers of the object
// that has been written.
//
// Must be called no more than once. Control remains with the caller.
// Re-calling can lead to undefined behavior
// that depends on the implementation.
Close(context.Context) (*AccessIdentifiers, error)
}
// TargetInitializer represents ObjectWriter constructor.
type TargetInitializer func() ObjectWriter
// ObjectWriter is an interface of the object writer that writes prepared object.
type ObjectWriter interface {
// WriteObject writes prepared object.
WriteObject(context.Context, *object.Object) error
}