{"modulePath":"github.com/github/git-lfs","version":"v2.5.2+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tq\n\nPackage 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\n\n## Constants\n\n```go\nconst (\n\tUpload   = Direction(iota)\n\tDownload = Direction(iota)\n\tCheckout = Direction(iota)\n)\n```\n\n```go\nconst (\n\tTusAdapterName = \"tus\"\n\tTusVersion     = \"1.0.0\"\n)\n```\n\n```go\nconst (\n\tBasicAdapterName = \"basic\"\n)\n```\n\n## Functions\n\n```go\nfunc IsActionExpiredError(err error) bool\n```\n\n```go\nfunc NewCustomAdapterDownloadRequest(oid string, size int64, action *Action) *customAdapterTransferRequest\n```\n\n```go\nfunc NewCustomAdapterInitRequest(\n\top string, remote string, concurrent bool, concurrentTransfers int,\n) *customAdapterInitRequest\n```\n\n```go\nfunc NewCustomAdapterTerminateRequest() *customAdapterTerminateRequest\n```\n\n```go\nfunc NewCustomAdapterUploadRequest(oid string, size int64, path string, action *Action) *customAdapterTransferRequest\n```\n\n## Types\n\n```go\ntype Action struct {\n\tHref      string            `json:\"href\"`\n\tHeader    map[string]string `json:\"header,omitempty\"`\n\tExpiresAt time.Time         `json:\"expires_at,omitempty\"`\n\tExpiresIn int               `json:\"expires_in,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (a *Action) IsExpiredWithin(d time.Duration) (time.Time, bool)\n```\n\n```go\ntype ActionExpiredErr struct {\n\tRel string\n\tAt  time.Time\n}\n```\n\n```go\nfunc (e ActionExpiredErr) Error() string\n```\n\n```go\ntype ActionSet map[string]*Action\n```\n\n```go\nfunc (as ActionSet) Get(rel string) (*Action, error)\n```\n\n```go\ntype Adapter interface {\n\t// Name returns the name of this adapter, which is the same for all instances\n\t// of this type of adapter\n\tName() string\n\t// Direction returns whether this instance is an upload or download instance\n\t// Adapter instances can only be one or the other, although the same\n\t// type may be instantiated for each direction\n\tDirection() Direction\n\t// Begin a new batch of uploads or downloads. Call this first, followed by\n\t// one or more Add calls. maxConcurrency controls the number of transfers\n\t// that may be done at once. The passed in callback will receive updates on\n\t// progress. Either argument may be nil if not required by the client.\n\tBegin(cfg AdapterConfig, cb ProgressCallback) error\n\t// Add queues a download/upload, which will complete asynchronously and\n\t// notify the callbacks given to Begin()\n\tAdd(transfers ...*Transfer) (results \u003c-chan TransferResult)\n\t// Indicate that all transfers have been scheduled and resources can be released\n\t// once the queued items have completed.\n\t// This call blocks until all items have been processed\n\tEnd()\n\t// ClearTempStorage clears any temporary files, such as unfinished downloads that\n\t// would otherwise be resumed\n\tClearTempStorage() error\n}\n```\nAdapter 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 \u0026 standard but Adapter can be changed to physically transfer to different hosts with less code.\n\n```go\ntype AdapterConfig interface {\n\tAPIClient() *lfsapi.Client\n\tConcurrentTransfers() int\n\tRemote() string\n}\n```\n\n```go\ntype BatchResponse struct {\n\tObjects             []*Transfer `json:\"objects\"`\n\tTransferAdapterName string      `json:\"transfer\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc Batch(m *Manifest, dir Direction, remote string, remoteRef *git.Ref, objects []*Transfer) (*BatchResponse, error)\n```\n\n```go\ntype Direction int\n```\n\n```go\nfunc (d Direction) String() string\n```\n\n```go\nfunc (d Direction) Verb() string\n```\nVerb returns a string containing the verb form of the receiving action.\n\n```go\ntype Env interface {\n\tGet(key string) (val string, ok bool)\n\tGetAll(key string) []string\n\tBool(key string, def bool) (val bool)\n\tInt(key string, def int) (val int)\n\tAll() map[string][]string\n}\n```\nEnv is any object with a config.Environment interface.\n\n```go\ntype MalformedObjectError struct {\n\tName string\n\tOid  string\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (e MalformedObjectError) Corrupt() bool\n```\n\n```go\nfunc (e MalformedObjectError) Error() string\n```\n\n```go\nfunc (e MalformedObjectError) Missing() bool\n```\n\n```go\ntype Manifest struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewManifest(f *fs.Filesystem, apiClient *lfsapi.Client, operation, remote string) *Manifest\n```\n\n```go\nfunc (m *Manifest) APIClient() *lfsapi.Client\n```\n\n```go\nfunc (m *Manifest) ConcurrentTransfers() int\n```\n\n```go\nfunc (m *Manifest) GetAdapterNames(dir Direction) []string\n```\nGetAdapterNames returns a list of the names of adapters available to be created\n\n```go\nfunc (m *Manifest) GetDownloadAdapterNames() []string\n```\nGetDownloadAdapterNames returns a list of the names of download adapters available to be created\n\n```go\nfunc (m *Manifest) GetUploadAdapterNames() []string\n```\nGetUploadAdapterNames returns a list of the names of upload adapters available to be created\n\n```go\nfunc (m *Manifest) IsStandaloneTransfer() bool\n```\n\n```go\nfunc (m *Manifest) MaxRetries() int\n```\n\n```go\nfunc (m *Manifest) NewAdapter(name string, dir Direction) Adapter\n```\nCreate a new adapter by name and direction, or nil if doesn't exist\n\n```go\nfunc (m *Manifest) NewAdapterOrDefault(name string, dir Direction) Adapter\n```\nCreate a new adapter by name and direction; default to BasicAdapterName if doesn't exist\n\n```go\nfunc (m *Manifest) NewDownloadAdapter(name string) Adapter\n```\nCreate a new download adapter by name, or BasicAdapterName if doesn't exist\n\n```go\nfunc (m *Manifest) NewUploadAdapter(name string) Adapter\n```\nCreate a new upload adapter by name, or BasicAdapterName if doesn't exist\n\n```go\nfunc (m *Manifest) RegisterNewAdapterFunc(name string, dir Direction, f NewAdapterFunc)\n```\nRegisterNewTransferAdapterFunc registers a new function for creating upload or download adapters. If a function with that name \u0026 direction is already registered, it is overridden\n\n```go\ntype Meter struct {\n\tDryRun    bool\n\tLogger    *tools.SyncWriter\n\tDirection Direction\n\t// contains filtered or unexported fields\n}\n```\nMeter provides a progress bar type output for the TransferQueue. It is given an estimated file count and size up front and tracks the number of files and bytes transferred as well as the number of files and bytes that get skipped because the transfer is unnecessary.\n\n```go\nfunc NewMeter() *Meter\n```\nNewMeter creates a new Meter.\n\n```go\nfunc (m *Meter) Add(size int64)\n```\nAdd tells the progress meter that a single file of the given size will possibly be transferred. If a file doesn't need to be transferred for some reason, be sure to call Skip(int64) with the same size.\n\n```go\nfunc (m *Meter) Finish()\n```\nFinish shuts down the Meter.\n\n```go\nfunc (m *Meter) FinishTransfer(name string)\n```\nFinishTransfer increments the finished transfer count\n\n```go\nfunc (m *Meter) Flush()\n```\nFlush sends the latest progress update, while leaving the meter active.\n\n```go\nfunc (m *Meter) LoggerFromEnv(os env) *tools.SyncWriter\n```\n\n```go\nfunc (m *Meter) LoggerToFile(name string) *tools.SyncWriter\n```\n\n```go\nfunc (m *Meter) Pause()\n```\nPause stops sending status updates temporarily, until Start() is called again.\n\n```go\nfunc (m *Meter) Skip(size int64)\n```\nSkip tells the progress meter that a file of size \\`size\\` is being skipped because the transfer is unnecessary.\n\n```go\nfunc (m *Meter) Start()\n```\nStart begins sending status updates to the optional log file, and stdout.\n\n```go\nfunc (m *Meter) StartTransfer(name string)\n```\nStartTransfer tells the progress meter that a transferring file is being added to the TransferQueue.\n\n```go\nfunc (m *Meter) Throttled() bool\n```\n\n```go\nfunc (m *Meter) TransferBytes(direction, name string, read, total int64, current int)\n```\nTransferBytes increments the number of bytes transferred\n\n```go\nfunc (m *Meter) Updates() \u003c-chan *tasklog.Update\n```\n\n```go\ntype NewAdapterFunc func(name string, dir Direction) Adapter\n```\nNewAdapterFunc 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\n\n```go\ntype ObjectError struct {\n\tCode    int    `json:\"code\"`\n\tMessage string `json:\"message\"`\n}\n```\n\n```go\nfunc (e *ObjectError) Error() string\n```\n\n```go\ntype Option func(*TransferQueue)\n```\n\n```go\nfunc DryRun(dryRun bool) Option\n```\n\n```go\nfunc RemoteRef(ref *git.Ref) Option\n```\n\n```go\nfunc WithBatchSize(size int) Option\n```\n\n```go\nfunc WithBufferDepth(depth int) Option\n```\n\n```go\nfunc WithProgress(m *Meter) Option\n```\n\n```go\nfunc WithProgressCallback(cb tools.CopyCallback) Option\n```\n\n```go\ntype ProgressCallback func(name string, totalSize, readSoFar int64, readSinceLast int) error\n```\n\n```go\ntype Transfer struct {\n\tName          string       `json:\"name,omitempty\"`\n\tOid           string       `json:\"oid,omitempty\"`\n\tSize          int64        `json:\"size\"`\n\tAuthenticated bool         `json:\"authenticated,omitempty\"`\n\tActions       ActionSet    `json:\"actions,omitempty\"`\n\tLinks         ActionSet    `json:\"_links,omitempty\"`\n\tError         *ObjectError `json:\"error,omitempty\"`\n\tPath          string       `json:\"path,omitempty\"`\n}\n```\n\n```go\nfunc (t *Transfer) Rel(name string) (*Action, error)\n```\n\n```go\ntype TransferQueue struct {\n\t// contains filtered or unexported fields\n}\n```\nTransferQueue 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.\n\n```go\nfunc NewTransferQueue(dir Direction, manifest *Manifest, remote string, options ...Option) *TransferQueue\n```\nNewTransferQueue builds a TransferQueue, direction and underlying mechanism determined by adapter\n\n```go\nfunc (q *TransferQueue) Add(name, path, oid string, size int64)\n```\nAdd 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.\n\nIf another transfer(s) with the same OID has been added to the \\*TransferQueue already, the given transfer will not be enqueued, but will be sent to any channel created by Watch() once the oldest transfer has completed.\n\nOnly one file will be transferred to/from the Path element of the first transfer.\n\n```go\nfunc (q *TransferQueue) BatchSize() int\n```\nBatchSize returns the batch size of the receiving \\*TransferQueue, or, the number of transfers to accept before beginning work on them.\n\n```go\nfunc (q *TransferQueue) Errors() []error\n```\nErrors returns any errors encountered during transfer.\n\n```go\nfunc (q *TransferQueue) Skip(size int64)\n```\n\n```go\nfunc (q *TransferQueue) Wait()\n```\nWait 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.\n\n```go\nfunc (q *TransferQueue) Watch() chan *Transfer\n```\nWatch returns a channel where the queue will write the value of each transfer as it completes. If multiple transfers exist with the same OID, they will all be recorded here, even though only one actual transfer took place. The channel will be closed when the queue finishes processing.\n\n```go\ntype TransferResult struct {\n\tTransfer *Transfer\n\t// This will be non-nil if there was an error transferring this item\n\tError error\n}\n```\nResult of a transfer returned through CompletionChannel()\n\n","path":"github.com/github/git-lfs/tq","name":"tq","synopsis":"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","isRedistributable":true}
