localdb

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: ISC Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	UserdbPath              = "users"
	LastPaywallAddressIndex = "lastpaywallindex"

	UserVersion    uint32 = 1
	UserVersionKey        = "userversion"
)

Variables

This section is empty.

Functions

func DecodeUser

func DecodeUser(payload []byte) (*database.User, error)

DecodeUser decodes a JSON byte slice into a User.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func EncodeUser

func EncodeUser(u database.User) ([]byte, error)

EncodeUser encodes User into a JSON byte slice.

func EncodeVersion

func EncodeVersion(version Version) ([]byte, error)

EncodeVersion encodes Version into a JSON byte slice.

func New

func New(root string) (*localdb, error)

New creates a new localdb instance.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type Version

type Version struct {
	Version uint32 `json:"version"` // Database version
	Time    int64  `json:"time"`    // Time of record creation
}

Version contains the database version.

func DecodeVersion

func DecodeVersion(payload []byte) (*Version, error)

DecodeVersion decodes a JSON byte slice into a Version.

Jump to

Keyboard shortcuts

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