store

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 15 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

This section is empty.

Types

type BadgerStore added in v0.9.0

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

func NewBadgerStore added in v0.9.0

func NewBadgerStore(path string, userID string, encryptionPassphrase []byte) (*BadgerStore, error)

func (*BadgerStore) Close added in v0.9.0

func (b *BadgerStore) Close() error

func (*BadgerStore) Delete added in v0.9.0

func (b *BadgerStore) Delete(messageID ...string) error

func (*BadgerStore) Get added in v0.9.0

func (b *BadgerStore) Get(messageID string) ([]byte, error)

func (*BadgerStore) Set added in v0.9.0

func (b *BadgerStore) Set(messageID string, literal []byte) error

func (*BadgerStore) Update added in v0.9.0

func (b *BadgerStore) Update(oldID, newID string) error

type BadgerStoreBuilder added in v0.9.0

type BadgerStoreBuilder struct{}

func (*BadgerStoreBuilder) New added in v0.9.0

func (*BadgerStoreBuilder) New(directory, userID, encryptionPassphrase string) (Store, error)

type Compressor

type Compressor interface {
	Compress([]byte) ([]byte, error)
	Decompress([]byte) ([]byte, error)
}

type GZipCompressor

type GZipCompressor struct{}

func (GZipCompressor) Compress

func (GZipCompressor) Compress(dec []byte) ([]byte, error)

func (GZipCompressor) Decompress

func (GZipCompressor) Decompress(cmp []byte) ([]byte, error)

type OnDiskStoreBuilder added in v0.9.0

type OnDiskStoreBuilder struct{}

func (*OnDiskStoreBuilder) New added in v0.9.0

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

type Option

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

func WithCompressor

func WithCompressor(cmp Compressor) 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) *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 string) ([]byte, error)
	Set(messageID string, literal []byte) error
	Update(oldID, newID string) error
	Delete(messageID ...string) error
	Close() error
}

func NewInMemoryStore

func NewInMemoryStore() Store

func NewOnDiskStore

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

type StoreBuilder added in v0.9.0

type StoreBuilder interface {
	New(directory, userID string, encryptionPassphrase []byte) (Store, error)
}

type ZLibCompressor

type ZLibCompressor struct{}

func (ZLibCompressor) Compress

func (ZLibCompressor) Compress(dec []byte) ([]byte, error)

func (ZLibCompressor) Decompress

func (ZLibCompressor) Decompress(cmp []byte) ([]byte, 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