messagestore

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2015 License: BSD-2-Clause Imports: 8 Imported by: 2

Documentation

Overview

Package messagestore implements storage for messages.

Index

Constants

View Source
const Version = "0.0.1 very alpha"

Version of this release

Variables

View Source
var (
	// ErrDuplicate is returned if a message is a duplicate
	ErrDuplicate = errors.New("messagestore: Duplicate message")
	// ErrPostLimit is returned when a signer has posted more messages than allowed by calculation
	ErrPostLimit = errors.New("messagestore: Signer has reached post limit")
	// ErrNotFound is returned when a message was fetched that didn't exist
	ErrNotFound = errors.New("messagestore: Message not found")
	// MaxMessageSize is the size of an encoded repbin message
	MaxMessageSize = 87776
)
View Source
var CurrentTime = func() int64 { return time.Now().UTC().Unix() }

CurrentTime returns the current time in UTC

View Source
var MaxAgeRecipients = int64(31536000)

MaxAgeRecipients defines when to delete recipients that are not active anymore

View Source
var MaxAgeSigners = int64(31536000)

MaxAgeSigners defines when to delete signers that are not active anymore

Functions

This section is empty.

Types

type Store

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

Store implements a message store

func New

func New(driver, url, dir string, workers int) *Store

New Create a new message store at directory dir. Workers is the maximum concurrent access to an index

func (Store) ExpireFromFS

func (store Store) ExpireFromFS()

ExpireFromFS expires data based on filesystem last change

func (Store) ExpireFromIndex

func (store Store) ExpireFromIndex(cycles int)

ExpireFromIndex reads the expire index and expires messages as they are recorded

func (Store) Fetch

func (store Store) Fetch(messageID *[message.MessageIDSize]byte) ([]byte, error)

Fetch a message from storage, delete if it is a one-time message

func (Store) GetGlobalIndex

func (store Store) GetGlobalIndex(start int64, count int64) ([][]byte, int, error)

GetGlobalIndex returns the global index

func (Store) GetIndex

func (store Store) GetIndex(index *message.Curve25519Key, start int64, count int64) ([][]byte, int, error)

GetIndex returns the index for a key

func (Store) GetPeerStat

func (store Store) GetPeerStat(pubkey *[ed25519.PublicKeySize]byte) *structs.PeerStruct

GetPeerStat returns the last entry of peer statistics for pubkey

func (Store) MessageExists

func (store Store) MessageExists(messageID [message.MessageIDSize]byte) bool

MessageExists returns true if the message exists

func (Store) PreExpire

func (store Store) PreExpire(messageID *[message.MessageIDSize]byte, pubkey *message.Curve25519Key) error

PreExpire expires a message in the next expire run

func (Store) Put

func (store Store) Put(msgStruct *structs.MessageStruct, signerStruct *structs.SignerStruct, message []byte) error

Put stores a message in the message store WITHOUT notifying the notify backend

func (Store) PutNotify

func (store Store) PutNotify(msgStruct *structs.MessageStruct, signerStruct *structs.SignerStruct, message []byte, notifyChan chan bool) error

PutNotify runs Put and notifies the backend if no error occured

func (Store) TouchPeer

func (store Store) TouchPeer(pubkey *[ed25519.PublicKeySize]byte)

TouchPeer creates a peer entry if it does not exist yet

func (Store) UpdatePeerAuthToken

func (store Store) UpdatePeerAuthToken(senderPubKey *[ed25519.PublicKeySize]byte, signedToken *[keyproof.ProofTokenSignedSize]byte)

UpdatePeerAuthToken updates the peer record when a new auth token has been received

func (Store) UpdatePeerFetchStat

func (store Store) UpdatePeerFetchStat(pubkey *[ed25519.PublicKeySize]byte, lastFetch, lastPos, lastErrors uint64)

UpdatePeerFetchStat writes fetch-specific data

func (Store) UpdatePeerNotification

func (store Store) UpdatePeerNotification(pubkey *[ed25519.PublicKeySize]byte, hasError bool)

UpdatePeerNotification updates the peer stat after notification send

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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