Documentation
¶
Overview ¶
Package multipart serves the JFrog CLI's multipart upload protocol, as the pinned jfrog-client-go drives it (artifactory/services/utils/ multipartupload.go): create a session, get a URL per part, PUT the parts concurrently, complete with the file's SHA-1, poll the status, and abort on failure. Once the status is FINISHED the CLI checksum-deploys the file, so a session only has to store the content and index it; the item, its properties and the package index come from that ordinary checksum deploy.
Artifactory hands out presigned S3 URLs and the object store assembles the parts. artifactweave serves the part URLs itself and keeps one blob.Store upload session per multipart upload (decision 0004), so every backend, mirror included, takes multipart uploads: parts are staged on local disk as they arrive, in any order, and appended to the blob upload in order. Only the parts that arrive ahead of a missing one wait on disk, a few times the part size with the CLI's concurrency.
Index ¶
- Constants
- Variables
- type Service
- func (s *Service) Abort(ctx context.Context, token string) error
- func (s *Service) Complete(ctx context.Context, token, sha1 string) error
- func (s *Service) Create(ctx context.Context, repo, repoPath string, partSizeMB int64, by string) (string, error)
- func (s *Service) Finished(ctx context.Context, token, by, sum string) (bool, error)
- func (s *Service) PartURL(ctx context.Context, token string, part int) (string, error)
- func (s *Service) PutPart(ctx context.Context, id string, part int, sig string, body io.Reader) error
- func (s *Service) Reap(ctx context.Context, u store.Upload) error
- func (s *Service) Status(ctx context.Context, token string) (Status, error)
- func (s *Service) Sweep(ctx context.Context) error
- type Status
Constants ¶
const ( StatusParts = "PARTS" StatusProcessing = "PROCESSING" StatusFinished = "FINISHED" StatusRetryable = "RETRYABLE_ERROR" StatusFailed = "NON_RETRYABLE_ERROR" StatusAborted = "ABORTED" )
Statuses the CLI's status poll understands.
const Backend = "jfrog-multipart"
Backend names multipart sessions in the uploads table, so the garbage collector hands them to Reap rather than to the blob store.
const ( // MaxPartSize bounds partSizeMB: S3's largest part, which Artifactory // passes the size to. MaxPartSize = 5 << 30 )
Variables ¶
var ( // ErrBadToken reports a token or part signature that does not verify. ErrBadToken = errors.New("multipart: invalid upload token") // ErrInvalid reports a malformed request. ErrInvalid = errors.New("multipart: invalid request") // ErrState reports a request the session's state does not allow, such as // a part after completion started. ErrState = errors.New("multipart: upload is not accepting this request") // ErrCorrupt reports a blob upload holding bytes its session cannot // account for. ErrCorrupt = errors.New("multipart: the blob upload and its session disagree") )
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
Store store.Store
Blobs blob.Store
Dir string
// Now supplies the time; nil means time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Service runs multipart uploads over a metadata store and a blob store. Dir holds the staged parts, a directory per upload.
func (*Service) Abort ¶
Abort discards an upload: its staged parts, its blob upload and its session. Content already completed stays stored.
func (*Service) Complete ¶
Complete starts assembling the upload, checked against sha1, and returns at once: the CLI polls Status. Completing an upload that is already finished or being completed in this process changes nothing.
func (*Service) Create ¶
func (s *Service) Create( ctx context.Context, repo, repoPath string, partSizeMB int64, by string, ) (string, error)
Create starts an upload of repoPath in repo, whose caller by is already authorised to deploy there, and returns its token: "<id>.<secret>".
func (*Service) Finished ¶
Finished reports whether token is the checksum token of a finished upload that by made of the content with SHA-256 sum. That content is indexed with no item yet, so the checksum deploy that stores the item finds no file the caller may read; this lets it through instead, for that caller and that content only. A token that opens nothing is false rather than an error, so the deploy goes on to its other checks.
func (*Service) PartURL ¶
PartURL returns the path and query the CLI PUTs part to, relative to the server's base URL. The CLI sends that request without credentials, so the URL carries a signature for that upload and part only.
func (*Service) PutPart ¶
func (s *Service) PutPart( ctx context.Context, id string, part int, sig string, body io.Reader, ) error
PutPart stages part of upload id from body and appends every part that is now next in line to the blob upload.
func (*Service) Reap ¶
Reap discards a stale session for the garbage collector, which found it in the uploads table under Backend.