casclient

package
v0.8.97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

Artifact Content Addressable Storage (CAS) Client code

Client code used to talk to the Artifact Storage Proxy.

It's a bytestream gRPC client that currently supports download by content digest (sha256) and upload methods.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// channel to send progress status to the go-routine that's rendering the progress bar
	ProgressStatus ProgressStatusChan
	// contains filtered or unexported fields
}

func New

func New(conn *grpc.ClientConn, opts ...ClientOpts) *Client

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, digest string) (*ResourceInfo, error)

Describe returns the metadata of a resource by its digest We use this to get the filename and the total size of the artifact

func (*Client) Download

func (c *Client) Download(ctx context.Context, w io.Writer, digest string) error

Download downloads a file from the CAS and writes it to the provided writer

func (*Client) IsReady added in v0.8.96

func (c *Client) IsReady(ctx context.Context) (bool, error)

Contact the API to check if the service is ready to accept connections

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, r io.Reader, filename, digest string) (*UpDownStatus, error)

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, filepath string) (*UpDownStatus, error)

Uploads a given file to a CAS server

type ClientOpts

type ClientOpts func(u *Client)

func WithLogger

func WithLogger(l zerolog.Logger) ClientOpts

type Downloader

type Downloader interface {
	Download(ctx context.Context, w io.Writer, digest string) error
	// Whether the CAS is ready to accept downloads
	IsReady(ctx context.Context) (bool, error)
}

type DownloaderUploader

type DownloaderUploader interface {
	Downloader
	Uploader
}

type ProgressStatusChan

type ProgressStatusChan chan (*UpDownStatus)

type ResourceInfo

type ResourceInfo struct {
	Digest   string
	Filename string
	Size     int64
}

type UpDownStatus

type UpDownStatus struct {
	Filename, Digest string
	ProcessedBytes   int64
}

type Uploader

type Uploader interface {
	UploadFile(ctx context.Context, filepath string) (*UpDownStatus, error)
	Upload(ctx context.Context, r io.Reader, digest, fileName string) (*UpDownStatus, error)
	// Whether the CAS is ready to accept uploads
	IsReady(ctx context.Context) (bool, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL