store

package
v0.0.0-...-d0c72dd Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const EventDispatcher = "MailStore"
View Source
const NewMailStoredEvent event.Event = "newMailStored"

Variables

View Source
var (
	AlreadyExistsError = errors.New("key already exists. Use Set() if you want to add/override key")
	KeyNotExistsError  = errors.New("given key does not exist")
)

Functions

This section is empty.

Types

type MailStore

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

MailStore holds a bunch of instances.Mail within a map and notifies via the message queue on mail updates

func CreateMailStore

func CreateMailStore(messageQueue event.Dispatcher) *MailStore

CreateMailStore always creates and returns a new MailStore. Needs a event.Dispatcher to notify others on mail updates

func (*MailStore) Add

func (store *MailStore) Add(key string, mailData instances.Mail) error

Add puts a instances.Mail into the internal map with the given key if the key not exists. Key can be any string but should be recreatable for receiving purposes Returns an AlreadyExistsError if key exists in Map

func (*MailStore) GetMultiple

func (store *MailStore) GetMultiple(keys []string) (mails map[string]instances.Mail, err error, notFoundKeys []string)

GetMultiple retrieves multiple mails for a given key slice. If any of the keys not exist, a KeyNotExistsError will be returned but the function will still gather the rest. Any not found key will be within the notFoundKeys return parameter

func (*MailStore) GetSingle

func (store *MailStore) GetSingle(key string) (instances.Mail, error)

GetSingle for retrieving a single mail by key. Returns KeyNotExistsError if given key does not exist in internal map.

func (*MailStore) Set

func (store *MailStore) Set(key string, data instances.Mail)

Set puts a instances.Mail into the internal map with the given key, regardless of key existence

Jump to

Keyboard shortcuts

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