Documentation ¶
Overview ¶
Package transfer collects together adapters for uploading and downloading LFS content NOTE: Subject to change, do not rely on this package from outside git-lfs source
Index ¶
- Constants
- func IsActionExpiredError(err error) bool
- func NewCustomAdapterDownloadRequest(oid string, size int64, action *Action) *customAdapterTransferRequest
- func NewCustomAdapterInitRequest(op string, concurrent bool, concurrentTransfers int) *customAdapterInitRequest
- func NewCustomAdapterTerminateRequest() *customAdapterTerminateRequest
- func NewCustomAdapterUploadRequest(oid string, size int64, path string, action *Action) *customAdapterTransferRequest
- type Action
- type ActionExpiredErr
- type ActionSet
- type Adapter
- type AdapterConfig
- type BatchResponse
- type Direction
- type Env
- type MalformedObjectError
- type Manifest
- func (m *Manifest) APIClient() *lfsapi.Client
- func (m *Manifest) ConcurrentTransfers() int
- func (m *Manifest) GetAdapterNames(dir Direction) []string
- func (m *Manifest) GetDownloadAdapterNames() []string
- func (m *Manifest) GetUploadAdapterNames() []string
- func (m *Manifest) MaxRetries() int
- func (m *Manifest) NewAdapter(name string, dir Direction) Adapter
- func (m *Manifest) NewAdapterOrDefault(name string, dir Direction) Adapter
- func (m *Manifest) NewDownloadAdapter(name string) Adapter
- func (m *Manifest) NewUploadAdapter(name string) Adapter
- func (m *Manifest) RegisterNewAdapterFunc(name string, dir Direction, f NewAdapterFunc)
- type NewAdapterFunc
- type ObjectError
- type Option
- type ProgressCallback
- type Transfer
- type TransferQueue
- type TransferResult
Constants ¶
const ( Upload = Direction(iota) Download = Direction(iota) )
const ( TusAdapterName = "tus" TusVersion = "1.0.0" )
const (
BasicAdapterName = "basic"
)
Variables ¶
This section is empty.
Functions ¶
func IsActionExpiredError ¶
func NewCustomAdapterTerminateRequest ¶
func NewCustomAdapterTerminateRequest() *customAdapterTerminateRequest
Types ¶
type Action ¶
type ActionExpiredErr ¶
func (ActionExpiredErr) Error ¶
func (e ActionExpiredErr) Error() string
type Adapter ¶
type Adapter interface { // Name returns the name of this adapter, which is the same for all instances // of this type of adapter Name() string // Direction returns whether this instance is an upload or download instance // Adapter instances can only be one or the other, although the same // type may be instantiated for each direction Direction() Direction // Begin a new batch of uploads or downloads. Call this first, followed by // one or more Add calls. maxConcurrency controls the number of transfers // that may be done at once. The passed in callback will receive updates on // progress. Either argument may be nil if not required by the client. Begin(cfg AdapterConfig, cb ProgressCallback) error // Add queues a download/upload, which will complete asynchronously and // notify the callbacks given to Begin() Add(transfers ...*Transfer) (results <-chan TransferResult) // Indicate that all transfers have been scheduled and resources can be released // once the queued items have completed. // This call blocks until all items have been processed End() // ClearTempStorage clears any temporary files, such as unfinished downloads that // would otherwise be resumed ClearTempStorage() error }
Adapter is implemented by types which can upload and/or download LFS file content to a remote store. Each Adapter accepts one or more requests which it may schedule and parallelise in whatever way it chooses, clients of this interface will receive notifications of progress and completion asynchronously. TransferAdapters support transfers in one direction; if an implementation provides support for upload and download, it should be instantiated twice, advertising support for each direction separately. Note that Adapter only implements the actual upload/download of content itself; organising the wider process including calling the API to get URLs, handling progress reporting and retries is the job of the core TransferQueue. This is so that the orchestration remains core & standard but Adapter can be changed to physically transfer to different hosts with less code.
type AdapterConfig ¶
type BatchResponse ¶
type Env ¶
type Env interface { Get(key string) (val string, ok bool) GetAll(key string) []string Bool(key string, def bool) (val bool) Int(key string, def int) (val int) All() map[string][]string }
Env is any object with a config.Environment interface.
type MalformedObjectError ¶
type MalformedObjectError struct { Name string Oid string // contains filtered or unexported fields }
func (MalformedObjectError) Corrupt ¶
func (e MalformedObjectError) Corrupt() bool
func (MalformedObjectError) Error ¶
func (e MalformedObjectError) Error() string
func (MalformedObjectError) Missing ¶
func (e MalformedObjectError) Missing() bool
type Manifest ¶
type Manifest struct {
// contains filtered or unexported fields
}
func NewManifest ¶
func NewManifest() *Manifest
func NewManifestWithClient ¶
func (*Manifest) ConcurrentTransfers ¶
func (*Manifest) GetAdapterNames ¶
GetAdapterNames returns a list of the names of adapters available to be created
func (*Manifest) GetDownloadAdapterNames ¶
GetDownloadAdapterNames returns a list of the names of download adapters available to be created
func (*Manifest) GetUploadAdapterNames ¶
GetUploadAdapterNames returns a list of the names of upload adapters available to be created
func (*Manifest) MaxRetries ¶
func (*Manifest) NewAdapter ¶
Create a new adapter by name and direction, or nil if doesn't exist
func (*Manifest) NewAdapterOrDefault ¶
Create a new adapter by name and direction; default to BasicAdapterName if doesn't exist
func (*Manifest) NewDownloadAdapter ¶
Create a new download adapter by name, or BasicAdapterName if doesn't exist
func (*Manifest) NewUploadAdapter ¶
Create a new upload adapter by name, or BasicAdapterName if doesn't exist
func (*Manifest) RegisterNewAdapterFunc ¶
func (m *Manifest) RegisterNewAdapterFunc(name string, dir Direction, f NewAdapterFunc)
RegisterNewTransferAdapterFunc registers a new function for creating upload or download adapters. If a function with that name & direction is already registered, it is overridden
type NewAdapterFunc ¶
NewAdapterFunc creates new instances of Adapter. Code that wishes to provide new Adapter instances should pass an implementation of this function to RegisterNewTransferAdapterFunc() on a *Manifest. name and dir are to provide context if one func implements many instances
type ObjectError ¶
func (*ObjectError) Error ¶
func (e *ObjectError) Error() string
type Option ¶
type Option func(*TransferQueue)
func WithBatchSize ¶
func WithBufferDepth ¶
func WithProgress ¶
type ProgressCallback ¶
type Transfer ¶
type Transfer struct { Name string `json:"name,omitempty"` Oid string `json:"oid,omitempty"` Size int64 `json:"size"` Authenticated bool `json:"authenticated,omitempty"` Actions ActionSet `json:"actions,omitempty"` Links ActionSet `json:"_links,omitempty"` Error *ObjectError `json:"error,omitempty"` Path string `json:"path,omitempty"` }
type TransferQueue ¶
type TransferQueue struct {
// contains filtered or unexported fields
}
TransferQueue organises the wider process of uploading and downloading, including calling the API, passing the actual transfer request to transfer adapters, and dealing with progress, errors and retries.
func NewTransferQueue ¶
func NewTransferQueue(dir Direction, manifest *Manifest, remote string, options ...Option) *TransferQueue
NewTransferQueue builds a TransferQueue, direction and underlying mechanism determined by adapter
func (*TransferQueue) Add ¶
func (q *TransferQueue) Add(name, path, oid string, size int64)
Add adds a *Transfer to the transfer queue. It only increments the amount of waiting the TransferQueue has to do if the *Transfer "t" is new.
func (*TransferQueue) Errors ¶
func (q *TransferQueue) Errors() []error
Errors returns any errors encountered during transfer.
func (*TransferQueue) Skip ¶
func (q *TransferQueue) Skip(size int64)
func (*TransferQueue) Wait ¶
func (q *TransferQueue) Wait()
Wait waits for the queue to finish processing all transfers. Once Wait is called, Add will no longer add transfers to the queue. Any failed transfers will be automatically retried once.
func (*TransferQueue) Watch ¶
func (q *TransferQueue) Watch() chan string
Watch returns a channel where the queue will write the OID of each transfer as it completes. The channel will be closed when the queue finishes processing.
type TransferResult ¶
type TransferResult struct { Transfer *Transfer // This will be non-nil if there was an error transferring this item Error error }
Result of a transfer returned through CompletionChannel()