backend

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Get(ctx context.Context, data Data) (Data, error)
	Put(ctx context.Context, data Data) error
	Close() error
}

func NewBoltBackend

func NewBoltBackend(dbPath string) (Backend, error)

func NewDummyBackend

func NewDummyBackend() Backend

NewDummyBackend returns a Backend. This backend does not store any data and always returns nil for error and echoes back the data

func NewFileBackend

func NewFileBackend(filePath string) Backend

type BoltBackend

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

func (*BoltBackend) Close

func (bb *BoltBackend) Close() error

func (*BoltBackend) Get

func (bb *BoltBackend) Get(ctx context.Context, data Data) (Data, error)

func (*BoltBackend) Put

func (bb *BoltBackend) Put(ctx context.Context, data Data) error

type Data

type Data struct {
	User       string    `json:"user"`
	UID        string    `json:"uid"`
	Hash       string    `json:"hash"`
	Direction  Direction `json:"direction"`
	SyncedTime time.Time `json:"synced_time"`
	Synced     bool      `json:"synced"`
}

type Direction

type Direction string
const (
	DirectionOut Direction = "out"
	DirectionIn  Direction = "in"
)

type DummyBackend

type DummyBackend struct{}

func (*DummyBackend) Close

func (b *DummyBackend) Close() error

func (*DummyBackend) Get

func (b *DummyBackend) Get(ctx context.Context, data Data) (Data, error)

func (*DummyBackend) Put

func (b *DummyBackend) Put(ctx context.Context, data Data) error

type FileBackend

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

func (*FileBackend) Close

func (fb *FileBackend) Close() error

func (*FileBackend) Get

func (fb *FileBackend) Get(ctx context.Context, data Data) (Data, error)

func (*FileBackend) Put

func (fb *FileBackend) Put(ctx context.Context, data Data) error

Jump to

Keyboard shortcuts

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