store

package
v0.0.0-...-71c93ef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultWaitTime = 100 * time.Millisecond

DefaultWaitTime is the default time to wait between retries.

Functions

This section is empty.

Types

type InMemory

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

func NewInMemory

func NewInMemory(spy *util.Spy) *InMemory

NewInMemory creates a new InMemory instance.

func (*InMemory) GetSpy

func (i *InMemory) GetSpy() *util.Spy

GetSpy returns the spy.

func (*InMemory) Marshal

func (i *InMemory) Marshal(ctx context.Context, raw interface{}) error

Marshal marshals the raw data and stores it. This is designed to make writing tests simpler.

func (*InMemory) Read

func (i *InMemory) Read(_ context.Context) ([]byte, error)

Read reads the file without acquiring the lock.

func (*InMemory) ReadForWrite

func (i *InMemory) ReadForWrite(_ context.Context) ([]byte, error)

ReadForWrite reads the file after acquiring the lock.

func (*InMemory) Unlock

func (i *InMemory) Unlock(_ context.Context) error

Unlock removes the lock.

func (*InMemory) Write

func (i *InMemory) Write(ctx context.Context, data []byte) error

Write writes the data to the file after acquiring the lock.

func (*InMemory) WriteLocked

func (i *InMemory) WriteLocked(_ context.Context, data []byte) error

WriteLocked writes data to the file after acquiring a lock used in pair with ReadForWrite. It returns an error if the lock file does not exist.

type Local

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

Local is a file-based Store implementation.

func NewLocal

func NewLocal(logger *log.Logger, fileName string) *Local

NewLocal creates a new file instance.

func (*Local) Read

func (l *Local) Read(_ context.Context) ([]byte, error)

Read reads the file without acquiring the lock.

func (*Local) ReadForWrite

func (l *Local) ReadForWrite(_ context.Context) ([]byte, error)

ReadForWrite reads the file after acquiring the lock.

func (*Local) Unlock

func (l *Local) Unlock(_ context.Context) error

Unlock removes the lock file. It returns an error if the lock file does not exist.

func (*Local) Write

func (l *Local) Write(ctx context.Context, data []byte) error

Write writes the data to the file after acquiring the lock.

func (*Local) WriteLocked

func (l *Local) WriteLocked(ctx context.Context, data []byte) error

WriteLocked writes data to the file after acquiring a lock used in pair with ReadForWrite. It returns an error if the lock file does not exist. It will unlock the file after writing.

type S3

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

S3 is a store that uses AWS S3 to store and retrieve data.

func NewS3

func NewS3(client *s3.Client, logger *log.Logger, bucket, path string) *S3

NewS3 creates a new S3 instance.

func (*S3) Delete

func (s *S3) Delete(ctx context.Context, path string) error

Delete deletes the S3 store.

func (*S3) Read

func (s *S3) Read(ctx context.Context) ([]byte, error)

Read reads the data from S3.

func (*S3) ReadForWrite

func (s *S3) ReadForWrite(ctx context.Context) ([]byte, error)

ReadForWrite reads the data from S3, but also locks it for later writing.

func (*S3) Unlock

func (s *S3) Unlock(ctx context.Context) error

Unlock unlocks the S3 store.

func (*S3) Write

func (s *S3) Write(ctx context.Context, data []byte) error

Write writes the data to S3.

func (*S3) WriteLocked

func (s *S3) WriteLocked(ctx context.Context, data []byte) error

WriteLocked writes the data to S3 and then unlocks it.

Jump to

Keyboard shortcuts

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