gcs_event_store

package
v0.0.0-...-282ba46 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, cfg *GCSConfig, options ...option.ClientOption) (storage.EventStore, error)

Types

type GCSConfig

type GCSConfig struct {
	Bucket  string
	Folder  *string
	Timeout Timeout
}

func Config

func Config(bucket string) *GCSConfig

func (*GCSConfig) NewContextWithTimeout

func (c *GCSConfig) NewContextWithTimeout(
	parent context.Context,
	operation Operation) (context.Context, context.CancelFunc)

NewContextWithTimeout generates a new context.Context with timeout from the parent context. If neither operation-specific timeout nor default timeout is found, return parent context without any operation.

func (*GCSConfig) WithFolder

func (c *GCSConfig) WithFolder(folder string) *GCSConfig

func (*GCSConfig) WithTimeout

func (c *GCSConfig) WithTimeout(timeout Timeout) *GCSConfig

type GCSEventStore

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

GCSEventStore persists the contents in GCS, which requires consistent connections to Google Cloud.

func (*GCSEventStore) LookUp

func (g *GCSEventStore) LookUp(ctx context.Context, key, source string) (*event.Message, error)

LookUp returns a single message by looking up the path `folder/key/source`.

func (*GCSEventStore) LookUpByKey

func (g *GCSEventStore) LookUpByKey(ctx context.Context, key string) ([]*event.Message, error)

LookUpByKey returns a list of messages by looking up the prefix `folder/key/`.

func (*GCSEventStore) Persist

func (g *GCSEventStore) Persist(ctx context.Context, key, source, content string) error

Persist uploads the message as a file on the path `folder/key/source`.

type Operation

type Operation string
const (
	ListContents Operation = "ListContents" // operation that lists all content associated with a given key
	ReadContent  Operation = "ReadContent"  // operation that reads content associated with a key-source pair
	WriteContent Operation = "WriteContent" //operation to writes content associated with a key-source pair
)

type Timeout

type Timeout struct {
	Default   *time.Duration              // the default timeout for all operations
	Operation map[Operation]time.Duration // the timeout of each operation - this overrides the default timeout
}

Jump to

Keyboard shortcuts

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