kvreceiptstore

package
v0.0.0-...-c7c8722 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedConditions []string

Functions

This section is empty.

Types

type Config

type Config struct {
	//kvdb config
	Database *kvdb.Config
	//Limit count limit,defalut value is notificationquque.DefaultStoreListLimit
	Limit int
	//RetentionDays data rretention in days
	RetentionDays int
}

StoreConfig key-value receipt store config

func (*Config) CreateStore

func (c *Config) CreateStore() (*Store, error)

CreateStore create store

type Filter

type Filter struct {
	Status             *notificationdelivery.DeliveryStatus
	InMessage          string
	NotificationFilter *notification.PlainFilter
}

func NewFilter

func NewFilter() *Filter

func (*Filter) ApplyCondition

func (f *Filter) ApplyCondition(cond *notification.Condition) error

ApplyCondition apply search condition to filter ErrConditionNotSupported should be returned if condition keyword is not supported

func (*Filter) FilterReceipt

func (f *Filter) FilterReceipt(r *notificationqueue.Receipt, ctx *notification.ConditionContext) (bool, error)

FilterReceipt filter receipt with given context Return if Receipt is valid

type Store

type Store struct {
	DB                *kvdb.Database
	DataRetentionDays int
	Limit             int
	// contains filtered or unexported fields
}

func New

func New() *Store

New create new Store

func (*Store) Close

func (s *Store) Close() error

Close close store and return any error if raised

func (*Store) Count

func (s *Store) Count(condition []*notification.Condition) (int, error)

Count count store with given search conditions

func (*Store) List

func (s *Store) List(condition []*notification.Condition, start string, asc bool, count int) (result []*notificationqueue.Receipt, iter string, err error)

List list no more than count notifactions in store with given search conditions form start position . Count should be greater than 0. Found receipts and next list position iter will be returned. Return largest id receipts if asc is false.

func (*Store) Open

func (s *Store) Open() error

Open open store and return any error if raised

func (*Store) Remove

func (s *Store) Remove(id string) (*notificationqueue.Receipt, error)

Remove remove receipt by given notification id and return removed receipt.

func (*Store) RetentionDays

func (s *Store) RetentionDays() (int, error)

RetentionDays log retention period in day.

func (*Store) Save

func (s *Store) Save(receipt *notificationqueue.Receipt) error

Save save given notificaiton to store. Receipt with same notification id will be overwritten.

func (*Store) SupportedConditions

func (s *Store) SupportedConditions() ([]string, error)

SupportedConditions return supported condition keyword list

Jump to

Keyboard shortcuts

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