loopback

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockObject

func MockObject(data []Chunk) *storagePluginStorageInfo

Types

type Bucket

type Bucket map[ObjectName]*storagePluginStorageInfo

type BucketName

type BucketName string

type Chunk

type Chunk []byte

type LoopbackHost

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

LoopbackHost provides a host plugin with functionality useful for certain kinds of testing.

It is not (currently) thread-safe.

Over time, if useful, it can be enhanced to do things like handle multiple hosts per set.

type LoopbackPlugin

type LoopbackPlugin struct {
	*TestPluginServer

	*LoopbackHost
	*LoopbackStorage
}

LoopbackPlugin provides a host and storage plugin with functionality useful for certain kinds of testing.

It is not (currently) thread-safe.

Over time, if useful, it can be enhanced to do things like handle multiple hosts per set.

func NewLoopbackPlugin

func NewLoopbackPlugin(opt ...TestOption) (*LoopbackPlugin, error)

NewLoopbackPlugin returns a new loopback pluginre For storage service testings NewLoopbackPlugin Supports WithMockErrors and WithMockBuckets as options. If no mock buckets are provided, a bucket named `default` will be created.

type LoopbackStorage

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

LoopbackStorage provides a storage plugin with functionality useful for certain kinds of testing.

It is thread-safe.

func (*LoopbackStorage) CloneBucket

func (l *LoopbackStorage) CloneBucket(name string) Bucket

CloneBucket returns a clone of the bucket. returns nil when the bucket is not found.

func (*LoopbackStorage) CloneStorageInfo

func (l *LoopbackStorage) CloneStorageInfo(bucketName, objectName string) *storagePluginStorageInfo

CloneStorageInfo returns a clone of the object stored in memory. Returns nil when the bucket or object is not found.

type Method

type Method uint8

Method is used to determine if an error should be returned to a specific storage plugin method.

const (
	// Any will return an error for any of the method defined in the storage plugin.
	Any Method = iota

	// Will return an error for the OnCreateStorageBucket method
	OnCreateStorageBucket

	// Will return an error for the OnUpdateStorageBucket method
	OnUpdateStorageBucket

	// Will return an error for the OnDeleteStorageBucket method
	OnDeleteStorageBucket

	// Will return an error for the ValidatePermissions method
	ValidatePermissions

	// Will return an error for the HeadObject method
	HeadObject

	// Will return an error for the GetObject method
	GetObject

	// Will return an error for the PutObject method
	PutObject
)

type ObjectName

type ObjectName string

type PluginMockError

type PluginMockError struct {
	BucketName   string
	BucketPrefix string
	ObjectKey    string
	ErrMsg       string
	ErrCode      codes.Code
	ErrMethod    Method
}

PluginMockError is used to mock an error when interacting with an external object store.

type PluginMockPutObjectResponse

type PluginMockPutObjectResponse struct {
	BucketName   string
	BucketPrefix string
	ObjectKey    string
	Response     *plgpb.PutObjectResponse
}

PluginMockPutObjectResponse is used to mock a response when calling putObject.

type TestOption

type TestOption func(*TestOptions) error

func WithChunkSize

func WithChunkSize(size int) TestOption

WithChunkSize provides an option to set the chunkSize used for grpc streams.

func WithMockBuckets

func WithMockBuckets(buckets map[BucketName]Bucket) TestOption

WithMockBuckets provides an option to create mocked external object store buckets.

func WithMockError

func WithMockError(err PluginMockError) TestOption

WithMockError provides an option to mock an error when interacting with an external object store.

func WithMockPutObjectResponse

func WithMockPutObjectResponse(response PluginMockPutObjectResponse) TestOption

type TestOptions

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

type TestPluginHostServer

TestPluginHostServer provides a host plugin service server where each method can be overwritten for tests.

func (TestPluginHostServer) ListHosts

func (TestPluginHostServer) NormalizeCatalogData

func (TestPluginHostServer) NormalizeSetData

func (TestPluginHostServer) OnCreateCatalog

func (TestPluginHostServer) OnCreateSet

func (TestPluginHostServer) OnDeleteCatalog

func (TestPluginHostServer) OnDeleteSet

func (TestPluginHostServer) OnUpdateCatalog

func (TestPluginHostServer) OnUpdateSet

type TestPluginServer

type TestPluginServer struct {
	TestPluginHostServer
	TestPluginStorageServer
}

TestPluginServer provides a host and storage plugin service server where each method can be overwritten for tests.

type TestPluginStorageServer

TestPluginStorageServer provides a storage plugin service server where each method can be overwritten for tests.

func (TestPluginStorageServer) GetObject

func (TestPluginStorageServer) HeadObject

func (TestPluginStorageServer) OnCreateStorageBucket

func (TestPluginStorageServer) OnDeleteStorageBucket

func (TestPluginStorageServer) OnUpdateStorageBucket

func (TestPluginStorageServer) PutObject

func (TestPluginStorageServer) ValidatePermissions

type WrappingPluginHostClient

type WrappingPluginHostClient struct {
	Server plgpb.HostPluginServiceServer
}

WrappingPluginHostClient provides a wrapper around a Server implementation that can be used when loading a plugin in-memory. Supports HostServiceServer

func (*WrappingPluginHostClient) ListHosts

func (*WrappingPluginHostClient) NormalizeCatalogData

func (*WrappingPluginHostClient) NormalizeSetData

func (*WrappingPluginHostClient) OnCreateCatalog

func (*WrappingPluginHostClient) OnCreateSet

func (*WrappingPluginHostClient) OnDeleteCatalog

func (*WrappingPluginHostClient) OnDeleteSet

func (*WrappingPluginHostClient) OnUpdateCatalog

func (*WrappingPluginHostClient) OnUpdateSet

type WrappingPluginStorageClient

type WrappingPluginStorageClient struct {
	Server plgpb.StoragePluginServiceServer
}

WrappingPluginStorageClient provides a wrapper around a Server implementation that can be used when loading a plugin in-memory. Supports StoragePluginServiceClient

func (*WrappingPluginStorageClient) GetObject

func (*WrappingPluginStorageClient) HeadObject

func (*WrappingPluginStorageClient) OnCreateStorageBucket

func (*WrappingPluginStorageClient) OnDeleteStorageBucket

func (*WrappingPluginStorageClient) OnUpdateStorageBucket

func (*WrappingPluginStorageClient) PutObject

func (*WrappingPluginStorageClient) ValidatePermissions

Jump to

Keyboard shortcuts

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