store

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

package store implements types that store message literals.

Messages may be stored either in-memory or on-disk. When stored on disk, they are stored encrypted and optionally compressed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCipher added in v0.15.0

func NewCipher(pass []byte) (cipher.AEAD, error)

Types

type Builder added in v0.10.0

type Builder interface {
	New(dir, userID string, passphrase []byte) (Store, error)
	Delete(dir, userID string) error
}

type Fallback added in v0.15.0

type Fallback interface {
	Read(gcm cipher.AEAD, reader io.Reader) ([]byte, error)

	Write(gcm cipher.AEAD, filepath string, data []byte) error
}

Fallback provides an interface to supply an alternative way to read a store file should the main route fail. This is mainly intended to allow users of the library to read old store formats they may have kept on disk. This is a stop-gap until a complete data migration cycle can be implemented in gluon.

type OnDiskStoreBuilder added in v0.9.0

type OnDiskStoreBuilder struct{}

func (*OnDiskStoreBuilder) Delete added in v0.12.0

func (*OnDiskStoreBuilder) Delete(path, userID string) error

func (*OnDiskStoreBuilder) New added in v0.9.0

func (*OnDiskStoreBuilder) New(path, userID string, passphrase []byte) (Store, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithFallback added in v0.15.0

func WithFallback(f Fallback) Option

func WithSemaphore

func WithSemaphore(sem *Semaphore) Option

type Semaphore

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

Semaphore implements a type used to limit concurrent operations.

func NewSemaphore

func NewSemaphore(max int, panicHandler async.PanicHandler) *Semaphore

NewSemaphore constructs a new semaphore with the given limit.

func (*Semaphore) Block

func (sem *Semaphore) Block()

Block prevents the semaphore from being locked.

func (*Semaphore) Do

func (sem *Semaphore) Do(fn func())

Do executes the given function synchronously.

func (*Semaphore) Go

func (sem *Semaphore) Go(fn func())

Go executes the given function asynchronously.

func (*Semaphore) Lock

func (sem *Semaphore) Lock()

Lock locks the semaphore, waiting first until it is possible.

func (*Semaphore) Unblock

func (sem *Semaphore) Unblock()

Unblock allows the semaphore to be locked again.

func (*Semaphore) Unlock

func (sem *Semaphore) Unlock()

Unlock unlocks the semaphore.

func (*Semaphore) Wait

func (sem *Semaphore) Wait()

Wait waits for all functions started by Go to finish executing.

type Store

type Store interface {
	Get(messageID imap.InternalMessageID) ([]byte, error)
	Set(messageID imap.InternalMessageID, reader io.Reader) error
	Delete(messageID ...imap.InternalMessageID) error
	Close() error
	List() ([]imap.InternalMessageID, error)
}

func NewOnDiskStore

func NewOnDiskStore(path string, pass []byte, opt ...Option) (Store, error)

type WriteControlledStore added in v0.15.0

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

WriteControlledStore ensures that a given file on disk can safely be accessed by multiple readers and only one writer. Internally we maintain a list of RWLocks per message ID.

func NewWriteControlledStore added in v0.15.0

func NewWriteControlledStore(impl Store) *WriteControlledStore

func (*WriteControlledStore) Close added in v0.15.0

func (w *WriteControlledStore) Close() error

func (*WriteControlledStore) Delete added in v0.15.0

func (w *WriteControlledStore) Delete(messageID ...imap.InternalMessageID) error

func (*WriteControlledStore) DeleteUnchecked added in v0.17.0

func (w *WriteControlledStore) DeleteUnchecked(messageIDs ...imap.InternalMessageID) error

DeleteUnchecked allows the user to bypass lock access. This will only work if you can guarantee that the data being delete is not being used anywhere.

func (*WriteControlledStore) Get added in v0.15.0

func (w *WriteControlledStore) Get(messageID imap.InternalMessageID) ([]byte, error)

func (*WriteControlledStore) List added in v0.15.0

func (*WriteControlledStore) Set added in v0.15.0

func (w *WriteControlledStore) Set(messageID imap.InternalMessageID, reader io.Reader) error

func (*WriteControlledStore) SetUnchecked added in v0.15.0

func (w *WriteControlledStore) SetUnchecked(messageID imap.InternalMessageID, reader io.Reader) error

SetUnchecked allows the user to bypass lock access. This will only work if you can guarantee that the data being set does not previously exit (e.g: New message).

type WriteControlledStoreBuilder added in v0.15.0

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

func NewWriteControlledStoreBuilder added in v0.15.0

func NewWriteControlledStoreBuilder(builder Builder) *WriteControlledStoreBuilder

func (*WriteControlledStoreBuilder) Delete added in v0.15.0

func (w *WriteControlledStoreBuilder) Delete(dir, userID string) error

func (*WriteControlledStoreBuilder) New added in v0.15.0

func (w *WriteControlledStoreBuilder) New(dir, userID string, passphrase []byte) (Store, error)

Directories

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

Jump to

Keyboard shortcuts

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