store

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func Extension added in v0.4.1

func Extension(ct ContentType, ce ContentEncoding) string

func FilePath added in v0.4.1

func FilePath(key string, headers *Headers) string

Types

type ContentEncoding

type ContentEncoding int
const (
	ContentEncodingPlain ContentEncoding = iota
	ContentEncodingGzip
	ContentEncodingZlib
	ContentEncodingFlate
)

func ParseContentEncoding

func ParseContentEncoding(compression string) (ContentEncoding, error)

func (ContentEncoding) FileExtension added in v0.4.1

func (ce ContentEncoding) FileExtension() string

func (ContentEncoding) FilePath added in v0.4.1

func (ce ContentEncoding) FilePath(key string) string

func (ContentEncoding) String

func (ce ContentEncoding) String() string

type ContentType

type ContentType int
const (
	ContentTypeUnknown ContentType = iota
	ContentTypeText
	ContentTypeJSON
	ContentTypeProtobuf
)

func ParseContentType

func ParseContentType(contentType string) (ContentType, error)

func (ContentType) FileExtension added in v0.4.1

func (ct ContentType) FileExtension() string

func (ContentType) FilePath added in v0.4.1

func (ct ContentType) FilePath(key string) string

func (ContentType) String

func (ct ContentType) String() string

type Headers

type Headers struct {
	// ContentType is the type of the object
	ContentType ContentType

	// ContentEncoding is the compression algorithm used to store the object.
	ContentEncoding ContentEncoding

	// KeyValue is a map of key-value pairs to store/load with the object.
	KeyValue map[string]string
}

Headers are optional metadata about an object to store/load

func (*Headers) GetContentEncoding

func (h *Headers) GetContentEncoding() (ContentEncoding, error)

func (*Headers) GetContentType

func (h *Headers) GetContentType() (string, error)

type Store

type Store interface {
	// Store stores an object in the store.
	//
	// The key is the identifier for the object.
	// The reader is the object to store.
	// The headers are optional metadata about the object.
	Store(ctx context.Context, key string, reader io.Reader, headers *Headers) error

	// Load loads an object from the store.
	//
	// The key is the identifier for the object.
	// The headers are optional metadata about the object.
	// It is the responsibility of the caller to close the returned reader
	Load(ctx context.Context, key string) (io.ReadCloser, *Headers, error)

	// Delete deletes an object from the store.
	Delete(ctx context.Context, key string) error

	// Copy copies an object from one store to another.
	Copy(ctx context.Context, srcKey, dstKey string) error
}

Store is an interface for storing and loading objects.

func NewNoOpStore added in v0.5.2

func NewNoOpStore() Store

NewNoOpStore returns a new no-op store.

func WithLog added in v0.3.0

func WithLog(store Store) Store

func WithMetrics added in v0.3.0

func WithMetrics(store Store) Store

func WithTags added in v0.3.0

func WithTags(store Store) Store

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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