fake

package
v0.0.173 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Lister
	Opener
}

A Client can list files and open them for reading.

type ConditionalClient

type ConditionalClient struct {
	UploadClient

	Lock *sync.RWMutex
	// contains filtered or unexported fields
}

ConditionalClient is a fake conditional client that can limit actions to matching conditions.

func (*ConditionalClient) Copy

func (cc *ConditionalClient) Copy(ctx context.Context, from, to gcs.Path) (*storage.ObjectAttrs, error)

Copy copies the contents of 'from' into 'to'.

func (*ConditionalClient) If

If returns a fake conditional client.

func (*ConditionalClient) Objects added in v0.0.100

func (cc *ConditionalClient) Objects(ctx context.Context, path gcs.Path, _, offset string) gcs.Iterator

Objects in the path.

func (*ConditionalClient) Open added in v0.0.100

Open the path conditionally.

func (*ConditionalClient) Stat added in v0.0.100

Stat about the path, such as size, generation, etc.

func (*ConditionalClient) Upload

func (cc *ConditionalClient) Upload(ctx context.Context, path gcs.Path, buf []byte, worldRead bool, cache string) (*storage.ObjectAttrs, error)

Upload writes content to the given path.

type Iterator

type Iterator struct {
	Objects []storage.ObjectAttrs
	Idx     int
	Err     int // must be > 0

	Offset  string
	ErrOpen error
	// contains filtered or unexported fields
}

An Iterator returns the attributes of the listed objects or an iterator.Done error.

func (*Iterator) Next

func (fi *Iterator) Next() (*storage.ObjectAttrs, error)

Next returns the next value.

type Lister

type Lister map[gcs.Path]Iterator

A Lister returns objects under a prefix.

func (Lister) Objects

func (fl Lister) Objects(ctx context.Context, path gcs.Path, _, offset string) gcs.Iterator

Objects returns an iterator of objects under a given path.

type Object

type Object struct {
	Data         string
	Attrs        *storage.ReaderObjectAttrs
	OpenOnRetry  bool // If true and OpenErr != nil, only error the first time Open() is called.
	OpenHasErred bool
	OpenErr      error
	ReadErr      error
	CloseErr     error
}

Object holds data for an object.

type Opener

type Opener struct {
	Paths map[gcs.Path]Object
	Lock  *sync.RWMutex
}

Opener opens given paths.

func (Opener) Open

Open returns a handle for a given path.

type Reader

type Reader struct {
	Buf      *bytes.Buffer
	ReadErr  error
	CloseErr error
}

A Reader reads a file.

func (*Reader) Close

func (fr *Reader) Close() error

Close closes a file.

func (*Reader) Read

func (fr *Reader) Read(p []byte) (int, error)

Read reads a file's contents.

type Stat

type Stat struct {
	Err   error
	Attrs storage.ObjectAttrs
}

Stat contains object attributes for a given path.

type Stater

type Stater map[gcs.Path]Stat

Stater stats given paths.

func (Stater) Stat

func (fs Stater) Stat(ctx context.Context, path gcs.Path) (*storage.ObjectAttrs, error)

Stat returns object attributes for a given path.

type Upload

type Upload struct {
	Buf          []byte
	CacheControl string
	WorldRead    bool
	Err          error
	Generation   int64
}

Upload represents an upload.

func (Upload) Attrs added in v0.0.73

func (u Upload) Attrs(path gcs.Path) *storage.ObjectAttrs

Attrs returns file attributes.

type UploadClient

type UploadClient struct {
	Client
	Uploader
	Stater
}

UploadClient is a fake upload client

func (UploadClient) If

func (fuc UploadClient) If(read, write *storage.Conditions) gcs.ConditionalClient

If returns a fake upload client.

type Uploader

type Uploader map[gcs.Path]Upload

Uploader adds upload capabilities to a fake client.

func (Uploader) Copy

func (fu Uploader) Copy(ctx context.Context, from, to gcs.Path) (*storage.ObjectAttrs, error)

Copy an object to the specified path

func (Uploader) Upload

func (fu Uploader) Upload(ctx context.Context, path gcs.Path, buf []byte, worldRead bool, cacheControl string) (*storage.ObjectAttrs, error)

Upload writes content to the given path.

Jump to

Keyboard shortcuts

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