patcher

package
v0.0.0-...-d342c0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReaderBufferSize = 64 * 1024
)

Variables

View Source
var (
	ErrOffsetExceedsSize       = errors.New("patch offset exceeds object size")
	ErrInvalidPatchOffsetOrder = errors.New("invalid patch offset order")
	ErrPayloadPatchIsNil       = errors.New("nil payload patch")
	ErrAttrPatchAlreadyApplied = errors.New("attribute patch already applied")
)

Functions

This section is empty.

Types

type Params

type Params struct {
	// Original object header.
	Header *objectSDK.Object

	// Range provider.
	RangeProvider RangeProvider

	// ObjectWriter is the writer that writes the patched object.
	ObjectWriter transformer.ChunkedObjectWriter

	// The size of the buffer used by the original payload range reader.
	// If it's set to <=0, then `DefaultReaderBufferSize` is used.
	ReaderBufferSize int
}

Params is parameters to initialize patcher.

type PatchApplier

type PatchApplier interface {
	// ApplyAttributesPatch applies the patch only for the object's attributes.
	//
	// ApplyAttributesPatch can't be invoked few times, otherwise it returns `ErrAttrPatchAlreadyApplied` error.
	//
	// The call is idempotent for the original header if it's invoked with empty `newAttrs` and
	// `replaceAttrs = false`.
	ApplyAttributesPatch(ctx context.Context, newAttrs []objectSDK.Attribute, replaceAttrs bool) error

	// ApplyPayloadPatch applies the patch for the object's payload.
	//
	// ApplyPayloadPatch returns `ErrPayloadPatchIsNil` error if patch is nil.
	ApplyPayloadPatch(ctx context.Context, payloadPatch *objectSDK.PayloadPatch) error

	// Close closes PatchApplier when the patch stream is over.
	Close(context.Context) (PatchRes, error)
}

PatchApplier is the interface that provides method to apply header and payload patches.

func New

func New(prm Params) PatchApplier

type PatchRes

type PatchRes struct {
	AccessIdentifiers *transformer.AccessIdentifiers
}

PatchRes is the result of patch application.

type RangeProvider

type RangeProvider interface {
	// GetRange reads an original object payload by the given range.
	// The method returns io.Reader over the data range only. This means if the data is read out,
	// then GetRange has to be invoked to provide reader over the next range.
	GetRange(ctx context.Context, rng *objectSDK.Range) io.Reader
}

RangeProvider is the interface that provides a method to get original object payload by a given range.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL