remotesapi

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2019 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package remotesapi implements a simple API for accessing all remotes and their online state as well as triggering syncs and diffs. Normally this involves at least three different APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Folder

type Folder struct {
	Folder           string `json:"folder"`
	ReadOnly         bool   `json:"read_only"`
	ConflictStrategy string `json:"conflict_strategy"`
}

Folder is a single folder limit for a remote.

type Identity

type Identity struct {
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
}

Identity describes our own repository identity.

type Mock

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

Mock is for testing purposes whenever a normal RemotesAPI is needed. It stores remotes in memory and does not implement really syncing or diffing.

func NewMock

func NewMock(name, fingerprint string) *Mock

NewMock creates a new Mock. `name` and `fingerprint` will be returned

func (*Mock) Get

func (m *Mock) Get(name string) (*Remote, error)

Get a remote by `name`.

func (*Mock) List

func (m *Mock) List() ([]*Remote, error)

List all existing remotes.

func (*Mock) MakeDiff

func (m *Mock) MakeDiff(name string) (*catfs.Diff, error)

MakeDiff produces a diff to the remote with `name`.

func (*Mock) OnChange

func (m *Mock) OnChange(fn func())

OnChange register a callback to be called once the remote list changes.

func (*Mock) Remove

func (m *Mock) Remove(name string) error

Remove removes a remote by `name`.

func (*Mock) Self

func (m *Mock) Self() (Identity, error)

Self returns the identity of this repository.

func (*Mock) Set

func (m *Mock) Set(rm Remote) error

Set (i.e. add or modify) a remote. The mock implementation takes the isOnline, isAuthenticated and LastSeen info from the remote, in contrast to the real implementation.

func (*Mock) Sync

func (m *Mock) Sync(name string) error

Sync synchronizes the latest state of `name` with our latest state. The mock implementation does nothing currently.

type Remote

type Remote struct {
	Name              string    `json:"name"`
	Folders           []Folder  `json:"folders"`
	Fingerprint       string    `json:"fingerprint"`
	AcceptAutoUpdates bool      `json:"accept_auto_updates"`
	IsOnline          bool      `json:"is_online"`
	IsAuthenticated   bool      `json:"is_authenticated"`
	AcceptPush        bool      `json:"accept_push"`
	ConflictStrategy  string    `json:"conflict_strategy"`
	LastSeen          time.Time `json:"last_seen"`
}

Remote is a the result of List and Get.

type RemotesAPI

type RemotesAPI interface {
	List() ([]*Remote, error)
	Get(name string) (*Remote, error)
	Set(rm Remote) error
	Remove(name string) error
	Self() (Identity, error)
	OnChange(fn func())

	Sync(name string) error
	MakeDiff(name string) (*catfs.Diff, error)
}

RemotesAPI provides a simpler interface to accessing remote information from repo.Repository, net.PeerServer and events.EventListener.

Jump to

Keyboard shortcuts

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