segmenttracker

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchScheduler

type BatchScheduler interface {
	Schedule(batchItem metaclient.BatchItem)
}

BatchScheduler schedules batch items to be issued.

type Segment

type Segment interface {
	Position() metaclient.SegmentPosition
	EncryptETag([]byte) ([]byte, error)
}

Segment represents a segment being tracked.

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker tracks segments as they are completed for the purpose of encrypting and setting the eTag on the final segment. It hold backs scheduling of the last known segment until Flush is called, at which point it verifies that the held back segment is indeed the last segment, encrypts the eTag using that segment, and injects it into the batch item that commits that segment (i.e. MakeInlineSegment or CommitSegment). If the segments are not part of a multipart upload (i.e. no eTag to apply), then the tracker schedules the segment batch items immediately.

func New

func New(scheduler BatchScheduler, eTagCh <-chan []byte) *Tracker

New returns a new tracker that uses the given batch scheduler to schedule segment commit items.

func (*Tracker) Flush

func (t *Tracker) Flush(ctx context.Context) (err error)

Flush schedules the held back segment. It must only be called at least one call to SegmentDone as well as SegmentsScheduled. It verifies that the held back segment is the last segment (as indicited by SegmentsScheduled). Before scheduling the last segment, it reads the eTag from the eTagCh channel provided in New, encryptes that eTag with the last segment, and then injects the encrypted eTag into the batch item that commits that segment (i.e. MakeInlineSegment or CommitSegment).

func (*Tracker) SegmentDone

func (t *Tracker) SegmentDone(segment Segment, batchItem metaclient.BatchItem)

SegmentDone notifies the tracker that a segment upload has completed and supplies the batchItem that needs to be scheduled to commit the segment ( or create the inline segment). If this is the last segment seen so far, it will not be scheduled immediately, and will instead be scheduled when a later segment finishes or Flush is called. If the tracker was given a nil eTagCh channel, then the segment batch item is scheduled immediately.

func (*Tracker) SegmentsScheduled

func (t *Tracker) SegmentsScheduled(lastSegment Segment)

SegmentsScheduled is invoked when the last segment upload has been scheduled. It allows the tracker to verify that the held back segment is actually the last segment when Flush is called.

Jump to

Keyboard shortcuts

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