pstoreds

package
v0.0.0-...-ce94876 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTTLDatastore = errors.New("datastore must provide TTL support")
)

Functions

func NewAddrBook

func NewAddrBook(ctx context.Context, store ds.TxnDatastore, opts Options) (*dsAddrBook, error)

NewAddrBook initializes a new address book given a Datastore instance, a context for managing the TTL manager, and the interval at which the TTL manager should sweep the Datastore.

func NewKeyBook

func NewKeyBook(_ context.Context, store ds.TxnDatastore, _ Options) (pstore.KeyBook, error)

func NewPeerMetadata

func NewPeerMetadata(_ context.Context, store ds.Datastore, _ Options) (pstore.PeerMetadata, error)

NewPeerMetadata creates a metadata store backed by a persistent db. It uses gob for serialisation.

See `init()` to learn which types are registered by default. Modules wishing to store values of other types will need to `gob.Register()` them explicitly, or else callers will receive runtime errors.

func NewPeerstore

func NewPeerstore(ctx context.Context, store ds.TxnDatastore, opts Options) (pstore.Peerstore, error)

NewPeerstore creates a peerstore backed by the provided persistent datastore.

Types

type Options

type Options struct {
	// The size of the in-memory cache. A value of 0 or lower disables the cache.
	CacheSize uint

	// Sweep interval to expire entries, only used when TTL is *not* natively managed
	// by the underlying datastore.
	TTLInterval time.Duration

	// Number of times to retry transactional writes.
	WriteRetries uint
}

Configuration object for the peerstore.

func DefaultOpts

func DefaultOpts() Options

DefaultOpts returns the default options for a persistent peerstore: * Cache size: 1024 * TTL sweep interval: 1 second * WriteRetries: 5

Jump to

Keyboard shortcuts

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