syncer

package
v0.0.0-...-d87a525 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTx

func AddTx(tx *sqlx.Tx, vk *keys.EdX25519Key, b []byte, cipher Cipher) error

func InitTables

func InitTables(db *sqlx.DB) error

func PullIndexes

func PullIndexes(db *sqlx.DB) (map[keys.ID]int64, error)

func PushIndexes

func PushIndexes(db *sqlx.DB) (map[keys.ID]int64, error)

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

func Transact

func Transact(db *sqlx.DB, txFn func(*sqlx.Tx) error) (err error)

Transact creates and executes a transaction.

Types

type Cipher

type Cipher interface {
	Encrypt(b []byte, key *keys.EdX25519Key) ([]byte, error)
}

Cipher for encryption.

type Context

type Context struct {
	VID keys.ID
	Tx  *sqlx.Tx
}

Context is context for sync.

type CryptoBoxSealCipher

type CryptoBoxSealCipher struct{}

func (CryptoBoxSealCipher) Encrypt

func (c CryptoBoxSealCipher) Encrypt(b []byte, key *keys.EdX25519Key) ([]byte, error)

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type NoCipher

type NoCipher struct{}

func (NoCipher) Encrypt

func (c NoCipher) Encrypt(b []byte, key *keys.EdX25519Key) ([]byte, error)

type Receiver

type Receiver func(ctx *Context, events []*client.Event) error

Receiver is notified when events are received from the remote.

type Syncer

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

Syncer syncs.

func New

func New(db *sqlx.DB, client *client.Client, receiver Receiver) *Syncer

New creates a Syncer.

func (*Syncer) Pull

func (s *Syncer) Pull(ctx context.Context, key *api.Key) error

Pull from remote.

func (*Syncer) Push

func (s *Syncer) Push(ctx context.Context, key *api.Key) error

Push to remote.

func (*Syncer) Sync

func (s *Syncer) Sync(ctx context.Context, key *api.Key) error

Jump to

Keyboard shortcuts

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