storage

package
v0.0.0-...-65ae5a0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownDriver is returned when a driver is not recognised.
	ErrUnknownDriver = errors.New("unknown driver")
	// ErrDocumentInvalid is returned when a document is invalid.
	ErrDocumentInvalid = errors.New("document is invalid")
)

Functions

This section is empty.

Types

type AWSS3

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

AWS S3 is a storage implementation that stores all data in AWS S3.

func NewAWSS3

func NewAWSS3(region, bucket string) (*AWSS3, error)

NewAWSS3 returns a new AWS S3 storage implementation.

func (*AWSS3) Delete

func (a *AWSS3) Delete(doc *document.Document) error

Delete implements Storage.

func (*AWSS3) Stream

func (a *AWSS3) Stream() (<-chan *document.Document, error)

Stream implements Storage.

func (*AWSS3) WithEncryptionKey

func (a *AWSS3) WithEncryptionKey(key []byte) (Storage, error)

WithEncryptionKey sets the encryption key.

func (*AWSS3) Write

func (a *AWSS3) Write(doc *document.Document) error

Write implements Storage.

type Driver

type Driver string

Driver is a storage driver.

const (
	MemoryDriver Driver = "memory"
	AWS3Driver   Driver = "aws-s3"
)

type Memory

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

Memory is a storage implementation that stores all data in memory.

func NewMemory

func NewMemory() (*Memory, error)

NewMemory returns a new Memory storage implementation.

func (*Memory) Delete

func (m *Memory) Delete(doc *document.Document) error

Delete deletes a document from the storage.

func (*Memory) Stream

func (m *Memory) Stream() (<-chan *document.Document, error)

Stream streams documents from the storage.

func (*Memory) WithEncryptionKey

func (m *Memory) WithEncryptionKey(key []byte) (Storage, error)

WithEncryptionKey sets the encryption key.

func (*Memory) Write

func (m *Memory) Write(doc *document.Document) error

Write writes a document to the storage, if the document already exists with the same ID it will be overwritten.

type Storage

type Storage interface {
	// Write writes a document to the storage, if the document already exists
	// with the same ID it will be overwritten.
	Write(doc *document.Document) error
	// Delete deletes a document from the storage.
	Delete(doc *document.Document) error
	// Stream streams documents from the storage.
	Stream() (<-chan *document.Document, error)
}

Storage is an interface for storage implementations.

func New

func New(d Driver) (Storage, error)

New returns a new storage implementation.

Jump to

Keyboard shortcuts

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