fed

package module
v0.0.0-...-0aa804a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/* File int the specified folder are exported to the federation by default */
	TrackByDefault = iota
	/* Folder is checked for changes in quasi-realtime way. Typically used for data streaming */
	QuasiRealTime
)
View Source
const (
	New      UpdateState = "new"
	Newer                = "newer"
	Older                = "older"
	Conflict             = "conflict"
	Deleted              = "deleted"
)

Variables

This section is empty.

Functions

func Join

func Join(key string, token string, folder string) error

Types

type Action

type Action struct {
	Loc  string
	Type ActionType
}

type ActionType

type ActionType string
const (
	ApplyUpdate  ActionType = "update"
	IgnoreUpdate            = "ignore"
)

type Connection

type Connection interface {
	Close()

	/* NetStat provides statistic information about the available exchanges */
	NetStat() []NetStat

	/* AutoSync enables/disables the automatic Push and Pull from the Federation. The parameter is the delay
	between each sync. When 0 the sync is suspended */
	AutoSync(period time.Duration)

	/* Push changes to the federation */
	Push() int
	/* Pull changes from the federation */
	Pull() int

	/* GetState returns the current differences between the federation and the local files */
	GetState() State

	/* Merge applies the specified actions. It returns false if the state has changed in the meantime and the client
	is expected to call GetState again */
	Merge(stateId int64, actions []Action) bool

	/* Mount adds a folder to be replicated to the federation */
	Mount(folder string, options ...MountOption) error

	/* Define whether the file should be exported or not to the federation in case of changes */
	SetTracked(file string, tracked bool) error

	IsTracked(file string) bool

	/* GetAttr gets the attribute with secret for the file */
	GetAttr(file string, key string) ([]byte, error)

	/* SetAttr sets the attribute with secret for the file */
	SetAttr(file string, key string, value []byte) error

	/* Sync saves all changes to disk */
	Sync() error

	/* Retrieve an operational log */
	GetLog(name LogName, since time.Time) (Log, error)

	GetErrorLog(since time.Time) ErrorLog

	Watch(func(Event))

	/* Creates an invite for the federation node */
	Invite(key string, exchanges []string, removeSecrets bool) (string, error)
}

func MustOpen

func MustOpen(userId string, folder string, options ...Option) Connection

MustOpen ... is like Open but panic in case of error

func Open

func Open(userId string, folder string, options ...Option) (Connection, error)
Open ... opens a connection for the node fedId storing configuration in folder.

Id must be globally unique. Connections are cached

type ErrorLog

type ErrorLog map[string]ErrorRec

type ErrorRec

type ErrorRec struct {
	Time time.Time `json:"time"`
	Err  error     `json:"err"`
}

type Event

type Event struct {
	Loc       string    `json:"loc"`
	EventType EventType `json:"eventType"`
}

type EventType

type EventType string

type Log

type Log map[string]time.Time

type LogName

type LogName string

type MountOption

type MountOption int

type NetStat

type NetStat struct {
	Name           string
	ThroughputUp   int64
	ThroughputDown int64
}

type Option

type Option func(config *config_)

func WithFTP

func WithFTP(name, url, username, password string) Option

func WithFedID

func WithFedID(id string) Option

func WithSecret

func WithSecret(secret string) Option

func WithStoreMaxSize

func WithStoreMaxSize(size int64) Option

func WithStoreSpan

func WithStoreSpan(span time.Duration) Option

type State

type State struct {
	Id        int64
	ErrorLog  map[time.Time]string
	ExportLog map[time.Time]string
	Updates   map[string]Update
}

type Update

type Update struct {
	State   UpdateState `json:"state"`
	ModTime time.Time   `json:"modTime"`
	Delete  bool        `json:"delete"`
	// contains filtered or unexported fields
}

type UpdateState

type UpdateState string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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