git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/object/transformer/types.go (about)

     1  package transformer
     2  
     3  import (
     4  	"context"
     5  
     6  	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
     7  	oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
     8  )
     9  
    10  // AccessIdentifiers represents group of the object identifiers
    11  // that are returned after writing the object.
    12  // Consists of the ID of the stored object and the ID of the parent object.
    13  type AccessIdentifiers struct {
    14  	ParentID     *oid.ID
    15  	SelfID       oid.ID
    16  	ParentHeader *object.Object
    17  	Epoch        uint64
    18  }
    19  
    20  // EpochSource is a source for the current epoch.
    21  type EpochSource interface {
    22  	CurrentEpoch() uint64
    23  }
    24  
    25  // ChunkedObjectWriter is an interface of the object writer
    26  // that writes object chunked.
    27  type ChunkedObjectWriter interface {
    28  	// WriteHeader writes object header w/ payload part.
    29  	// The payload of the object may be incomplete.
    30  	//
    31  	// Must be called exactly once. Control remains with the caller.
    32  	// Missing a call or re-calling can lead to undefined behavior
    33  	// that depends on the implementation.
    34  	//
    35  	// Must not be called after Close call.
    36  	WriteHeader(context.Context, *object.Object) error
    37  
    38  	// Write writes object payload chunk.
    39  	//
    40  	// Can be called multiple times.
    41  	//
    42  	// Must not be called after Close call.
    43  	Write(context.Context, []byte) (int, error)
    44  
    45  	// Close is used to finish object writing.
    46  	//
    47  	// Close must return access identifiers of the object
    48  	// that has been written.
    49  	//
    50  	// Must be called no more than once. Control remains with the caller.
    51  	// Re-calling can lead to undefined behavior
    52  	// that depends on the implementation.
    53  	Close(context.Context) (*AccessIdentifiers, error)
    54  }
    55  
    56  // TargetInitializer represents ObjectWriter constructor.
    57  type TargetInitializer func() ObjectWriter
    58  
    59  // ObjectWriter is an interface of the object writer that writes prepared object.
    60  type ObjectWriter interface {
    61  	// WriteObject writes prepared object.
    62  	WriteObject(context.Context, *object.Object) error
    63  }