store

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 12 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 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 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
}

func NewInMemoryStore

func NewInMemoryStore() Store

func NewOnDiskStore

func NewOnDiskStore(path string, pass []byte, opt ...Option) (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