store

package
v0.0.0-...-a6a3a47 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnected = errors.New("not connected to target server/service")

ErrNotConnected - indicates that the target connection is not active.

Functions

func StreamItems

func StreamItems[I any](store Store[I], target Target, doneCh <-chan struct{}, logger logger)

StreamItems reads the keys from the store and replays the corresponding item to the target.

Types

type QueueStore

type QueueStore[_ any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

QueueStore - Filestore for persisting items.

func NewQueueStore

func NewQueueStore[I any](directory string, limit uint64, ext string) *QueueStore[I]

NewQueueStore - Creates an instance for QueueStore.

func (*QueueStore[_]) Del

func (store *QueueStore[_]) Del(key string) error

Del - Deletes an entry from the store.

func (*QueueStore[_]) Extension

func (store *QueueStore[_]) Extension() string

Extension will return the file extension used for the items stored in the queue.

func (*QueueStore[I]) Get

func (store *QueueStore[I]) Get(key string) (item I, err error)

Get - gets an item from the store.

func (*QueueStore[_]) Len

func (store *QueueStore[_]) Len() int

Len returns the entry count.

func (*QueueStore[_]) List

func (store *QueueStore[_]) List() ([]string, error)

List - lists all files registered in the store.

func (*QueueStore[_]) Open

func (store *QueueStore[_]) Open() error

Open - Creates the directory if not present.

func (*QueueStore[I]) Put

func (store *QueueStore[I]) Put(item I) error

Put - puts an item to the store.

type Store

type Store[I any] interface {
	Put(item I) error
	Get(key string) (I, error)
	Len() int
	List() ([]string, error)
	Del(key string) error
	Open() error
	Extension() string
}

Store - Used to persist items.

type Target

type Target interface {
	Name() string
	SendFromStore(key string) error
}

Target - store target interface

Jump to

Keyboard shortcuts

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