client.go

 1package lfs
 2
 3import (
 4	"context"
 5	"io"
 6)
 7
 8const (
 9	httpScheme  = "http"
10	httpsScheme = "https"
11)
12
13// DownloadCallback gets called for every requested LFS object to process its content.
14type DownloadCallback func(p Pointer, content io.ReadCloser, objectError error) error
15
16// UploadCallback gets called for every requested LFS object to provide its content.
17type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error)
18
19// Client is a Git LFS client to communicate with a LFS source API.
20type Client interface {
21	Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error
22	Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error
23}
24
25// NewClient returns a new Git LFS client.
26func NewClient(e Endpoint) Client {
27	if e.Scheme == httpScheme || e.Scheme == httpsScheme {
28		return newHTTPClient(e)
29	}
30	// TODO: support ssh client
31	return nil
32}