Back to godoc.org
github.com/luci/luci-go / common / isolatedclient

Package isolatedclient

v0.0.0-...-d4769a7
Latest Go to latest

The latest major version is .

Published: Aug 1, 2020 | License: Apache-2.0 | Module: github.com/luci/luci-go

Overview

Package isolatedclient implements the API to communicate with the Isolated server and to process '.isolated' files.

Index

Constants

const DefaultNamespace = "default-gzip"

DefaultNamespace is the namespace that should be used with the New function.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client to an isolated server.

func NewClient

func NewClient(host string, opts ...Option) *Client

NewClient returns a new IsolateServer client.

func (*Client) Contains

func (i *Client) Contains(c context.Context, items []*isolateservice.HandlersEndpointsV1Digest) (out []*PushState, err error)

Contains looks up cache presence on the server of multiple items.

The returned list is in the same order as 'items', with entries nil for items that were present.

func (*Client) Fetch

func (i *Client) Fetch(c context.Context, digest isolated.HexDigest, dest io.Writer) error

Fetch downloads an item from the server.

func (*Client) Hash

func (i *Client) Hash() crypto.Hash

Hash returns the hashing algorithm used for this client.

func (*Client) Push

func (i *Client) Push(c context.Context, state *PushState, source Source) (err error)

Push pushed a missing item, as reported by Contains(), to the server.

func (*Client) ServerCapabilities

func (i *Client) ServerCapabilities(c context.Context) (*isolateservice.HandlersEndpointsV1ServerDetails, error)

ServerCapabilities returns the server details.

type CloudStorage

type CloudStorage interface {
	// Fetch is a handler for retrieving specified content from GCS and storing
	// the response in the provided destination buffer.
	Fetch(context.Context, *Client, isolateservice.HandlersEndpointsV1RetrievedContent, io.Writer) error
	// Push is a handler for pushing content from provided buffer to GCS.
	Push(context.Context, *Client, isolateservice.HandlersEndpointsV1PreuploadStatus, Source) error
}

CloudStorage is the interface for clients to fetch from and push to GCS storage.

type Flags

type Flags struct {
	ServerURL string
	Namespace string
}

Flags contains values parsed from command line arguments.

func (*Flags) Init

func (c *Flags) Init(f *flag.FlagSet)

Init registers flags in a given flag set.

func (*Flags) NewClient

func (c *Flags) NewClient(opts ...Option) *Client

func (*Flags) Parse

func (c *Flags) Parse() error

Parse applies changes specified by command line flags.

type Option

type Option func(*Client)

func WithAnonymousClient

func WithAnonymousClient(c *http.Client) Option

WithAnonymousClient returns Option that sets client which will be used by gcsHandler.

func WithAuthClient

func WithAuthClient(c *http.Client) Option

WithAuthClient returns Option that sets client with authentication sufficient to talk to Isolate server (OAuth tokens with 'email' scope).

func WithGCSHandler

func WithGCSHandler(gcs CloudStorage) Option

func WithNamespace

func WithNamespace(namespace string) Option

func WithRetryFactory

func WithRetryFactory(rFn retry.Factory) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

type PushState

type PushState struct {
	// contains filtered or unexported fields
}

PushState is per-item state passed from IsolateServer.Contains() to IsolateServer.Push().

Its content is implementation specific.

type Source

type Source func() (io.ReadCloser, error)

Source is a generator method to return source data. A generated Source must be Closed before the generator is called again.

func NewBytesSource

func NewBytesSource(d []byte) Source

NewBytesSource returns a Source implementation that reads from the supplied byte slice.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier