backup

package
v0.2400.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package backup provides tools for backing up peers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Delete permanently removes all peers from the backup.
	Delete(ctx context.Context) error

	// Backup stores gives peers possibly overwriting the last backup.
	Backup(ctx context.Context, nsPeers map[string][]peer.AddrInfo) error

	// Restore returns peers from the last backup.
	Restore(ctx context.Context) (map[string][]peer.AddrInfo, error)
}

Backend is an interface used to backup and restore peer identities and addresses.

func NewCommonStoreBackend

func NewCommonStoreBackend(cs *persistent.CommonStore, bucket string, key string) Backend

NewCommonStoreBackend creates a new common store backend.

The name of the bucket and the key under which peers are stored should be unique to avoid backups to be overwritten.

type InMemoryBackend

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

InMemoryBackend uses memory to backup and restore peers. This backend is not persistent and intended for testing purposes only.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates a new in-memory backend.

func (*InMemoryBackend) Backup

func (b *InMemoryBackend) Backup(_ context.Context, nsPeers map[string][]peer.AddrInfo) error

Backup implements PeerBackup.

func (*InMemoryBackend) Delete

func (b *InMemoryBackend) Delete(context.Context) error

Delete implements PeerBackup.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(context.Context) (map[string][]peer.AddrInfo, error)

Restore implements PeerBackup.

Jump to

Keyboard shortcuts

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