persistence

package
Version: v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2017 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Errors

type Errors int

Errors persistence errors

const (
	// ErrInvalidArgs invalid arguments provided
	ErrInvalidArgs Errors = iota
	// ErrUnknownProvider if provider is unknown
	ErrUnknownProvider
	// ErrAlreadyExists object already exists
	ErrAlreadyExists
	// ErrNotInitialized persistence provider not initialized yet
	ErrNotInitialized
	// ErrNotFound object not found
	ErrNotFound
	// ErrNotOpen storage is not open
	ErrNotOpen

	// ErrBrokenEntry persisted entry does not meet requirements
	ErrBrokenEntry
)

func (Errors) Error

func (e Errors) Error() string

Errors description during persistence

type Packets

type Packets interface {
	PacketsForEach([]byte, func(PersistedPacket) error) error
	PacketsStore([]byte, []PersistedPacket) error
}

Packets interface for connection to handle packets

type PersistedPacket

type PersistedPacket struct {
	UnAck    bool
	ExpireAt string
	Data     []byte
}

PersistedPacket wraps packet to handle misc cases like expiration

type Provider

type Provider interface {
	Sessions() (Sessions, error)
	Retained() (Retained, error)
	System() (System, error)
	Shutdown() error
}

Provider interface implemented by different backends

func Default

func Default() Provider

Default allocate new persistence provider of in memory type

type ProviderConfig

type ProviderConfig interface{}

ProviderConfig interface implemented by every backend

type Retained

type Retained interface {
	// Store persist retained message
	Store([]PersistedPacket) error
	// Load load retained messages
	Load() ([]PersistedPacket, error)
	// Wipe retained storage
	Wipe() error
}

Retained provider for load/store retained messages

type SessionDelays

type SessionDelays struct {
	Since    string
	ExpireIn string
	WillIn   string
	WillData []byte
}

SessionDelays formerly known as expiry set timestamp to handle will delay and/or expiration

type SessionState

type SessionState struct {
	Subscriptions []byte
	Timestamp     string
	Errors        []error
	Expire        *SessionDelays
	Version       byte
}

SessionState object

type Sessions

type Sessions interface {
	Packets
	Subscriptions
	State
	LoadForEach(func([]byte, *SessionState) error) error
	PacketStore([]byte, PersistedPacket) error
	PacketsDelete([]byte) error
	Exists(id []byte) bool
	Delete([]byte) error
}

Sessions interface allows operating with sessions inside backend

type State

type State interface {
	StateStore([]byte, *SessionState) error
	StateDelete([]byte) error
}

State session state interface

type Subscriptions

type Subscriptions interface {
	SubscriptionsStore([]byte, []byte) error
	SubscriptionsDelete([]byte) error
}

Subscriptions session subscriptions interface

type System

type System interface {
	GetInfo() (*SystemState, error)
	SetInfo(*SystemState) error
}

System persistence state of the system configuration

type SystemState

type SystemState struct {
	Version  string
	NodeName string
}

SystemState system configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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