persistence

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package persistence provides storing/recovery mechanism for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recovery

type Recovery struct {
	Index             uint8      `json:"index"`
	TimeStamp         uint64     `json:"time_stamp"`
	RequestsInTenSec  [10]uint64 `json:"requests_10s"`
	ResponsesInTenSec [10]uint64 `json:"responses_10s"`
}

Recovery type manages data that should be recovered later on.

func NewEmptyRecovery

func NewEmptyRecovery() *Recovery

NewEmptyRecovery allocates and returns a new empty Recovery.

func NewRecovery

func NewRecovery(index uint8, timestamp uint64, requestsInTenSec, responsesInTenSec [10]uint64) *Recovery

NewRecovery allocates and returns a new Recovery from a given data to track the data that should be recovered later.

func (*Recovery) Marshal

func (r *Recovery) Marshal() ([]byte, error)

Marshal returns the JSON encoding of the recovery object.

func (*Recovery) Unmarshal

func (r *Recovery) Unmarshal(data []byte) error

Unmarshal parses the JSON-encoded recovery data.

type Saver

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

Saver is an interface for I/O operations.

func NewSaver

func NewSaver(filePath string) *Saver

NewSaver allocates and returns a new Saver.

func (*Saver) Close

func (s *Saver) Close() error

Close closes the underlying layer used for saving.

func (*Saver) Read

func (s *Saver) Read() ([]byte, error)

Read reads and returns saved data.

func (*Saver) Save

func (s *Saver) Save(data []byte) error

Save saves given data by truncating and overriding the current saved data.

Jump to

Keyboard shortcuts

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