storage

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailToMarshalData = apperrors.System(nil, "fail to marshal data", "FAIL_TO_MARSHAL_DATA")
	ErrFailToMarshalMeta = apperrors.System(nil, "fail to marshal data", "FAIL_TO_MARSHAL_META")
)

Functions

This section is empty.

Types

type Entry

type Entry[T model.IEntry] struct {
	Data   T
	Status Status
}

func (Entry[T]) Hash

func (e Entry[T]) Hash() ([]byte, error)

func (Entry[T]) Marshal

func (e Entry[T]) Marshal() ([]byte, error)

type FindByHasStoryOptions

type FindByHasStoryOptions struct {
	SourceNames []string
	Interval    time.Duration
	Limit       int
	Has         bool
}

type Options

type Options struct {
	TTL time.Duration `fig:"ttl" yaml:"ttl"`
}

type Status

type Status byte
const (
	StatusNew Status = iota + 1
	StatusSent
)

func (Status) Byte

func (s Status) Byte() byte

func (Status) Is

func (s Status) Is(status Status) bool

type Storage

type Storage[T model.IEntry] interface {
	Has(hash string) (bool, error)
	Store(entry Entry[T]) error
	FindByHasStory(opt FindByHasStoryOptions) ([]T, error)
	Update(entry Entry[T]) error
	Cleanup() (int64, error)
	Where(opts WhereOptions, list []T) ([]T, error)
}

type WhereOption

type WhereOption func(opts *WhereOptions)

func WhereAllowMissed

func WhereAllowMissed(allow bool) WhereOption

func WhereIs

func WhereIs(status Status) WhereOption

func WhereNot

func WhereNot(status Status) WhereOption

type WhereOptions

type WhereOptions struct {
	Is          *Status
	Not         *Status
	AllowMissed *bool
}

func Where

func Where(opts ...WhereOption) WhereOptions

func WhereNotSent

func WhereNotSent() WhereOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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