chunkstore

package
v0.0.0-...-110cdec Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileName

func FileName(project, objectID string) string

FileName returns the file path in GCS for the object with the given project and objectID. Exposed for testing only.

Types

type Client

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

Client provides methods to store and retrieve chunks of test failures.

func NewClient

func NewClient(ctx context.Context, bucket string) (*Client, error)

NewClient initialises a new chunk storage client, that uses the specified GCS bucket as the backing store.

func (*Client) Close

func (c *Client) Close()

Close releases resources associated with the client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, project, objectID string) (chunk *cpb.Chunk, retErr error)

Get retrieves the chunk with the specified object ID and returns it.

func (*Client) Put

func (c *Client) Put(ctx context.Context, project string, content *cpb.Chunk) (objectID string, retErr error)

Put saves the given chunk to storage. If successful, it returns the randomly-assigned ID of the created object.

type FakeClient

type FakeClient struct {
	// Contents are the chunk stored in the store, by their file name.
	// File names can be obtained using the FileName method.
	Contents map[string]*cpb.Chunk

	// A callback function to be called during Get(...). This allows
	// the test to change the environment during the processing of
	// a particular chunk.
	GetCallback func(objectID string)
}

FakeClient provides a fake implementation of a chunk store, for testing. Chunks are stored in-memory.

func NewFakeClient

func NewFakeClient() *FakeClient

NewFakeClient initialises a new FakeClient.

func (*FakeClient) Get

func (fc *FakeClient) Get(ctx context.Context, project, objectID string) (*cpb.Chunk, error)

Get retrieves the chunk with the specified object ID and returns it.

func (*FakeClient) Put

func (fc *FakeClient) Put(ctx context.Context, project string, content *cpb.Chunk) (string, error)

Put saves the given chunk to storage. If successful, it returns the randomly-assigned ID of the created object.

Jump to

Keyboard shortcuts

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