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 ¶
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 ¶
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.