common

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package common defines vars and constants for the sync package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirWithInternalSeparator

func DirWithInternalSeparator(filePath string) string

func IsIgnoredFile

func IsIgnoredFile(path string) (ignored bool)

func NodeRequiresChecksum added in v1.5.0

func NodeRequiresChecksum(node *tree.Node) bool

func PerformTests

func PerformTests(basePath string, externalPath string, testInfo chan string, testHeader chan string)

Types

type DataSyncSource

type DataSyncSource interface {
	PathSyncSource
	GetReaderOn(path string) (out io.ReadCloser, err error)
}

func AsDataSyncSource

func AsDataSyncSource(endpoint Endpoint) (DataSyncSource, bool)

type DataSyncTarget

type DataSyncTarget interface {
	PathSyncTarget
	GetWriterOn(path string, targetSize int64) (out io.WriteCloser, err error)
}

func AsDataSyncTarget

func AsDataSyncTarget(endpoint Endpoint) (DataSyncTarget, bool)

type Endpoint

type Endpoint interface {
	LoadNode(ctx context.Context, path string, leaf ...bool) (node *tree.Node, err error)
	GetEndpointInfo() EndpointInfo
}

type EndpointInfo

type EndpointInfo struct {
	RequiresNormalization bool
	RequiresFoldersRescan bool
}

type EventInfo

type EventInfo struct {
	Time           string
	Size           int64
	Etag           string
	Folder         bool
	Path           string
	PathSyncSource PathSyncSource
	Type           EventType
	Host           string
	Port           string
	UserAgent      string
	OperationId    string
	ScanEvent      bool
	ScanSourceNode *tree.Node
	Metadata       map[string]string
}

EventInfo contains the information of the event that occurred and the source IP:PORT of the client which triggerred the event.

func NodeToEventInfo

func NodeToEventInfo(ctx context.Context, path string, node *tree.Node, eventType EventType) (eventInfo EventInfo)

func (EventInfo) CreateContext

func (e EventInfo) CreateContext(ctx context.Context) context.Context

type EventType

type EventType string

EventType represents the type of the event occurred.

const (
	// EventCreate notifies when a new object is created
	EventCreate EventType = "ObjectCreated"
	// EventCreate notifies when a new object is created
	EventRename EventType = "ObjectRenamed"
	// EventRemove notifies when a new object is deleted
	EventRemove EventType = "ObjectRemoved"
	// EventAccessed notifies when an object is accessed.
	EventAccessed EventType = "ObjectAccessed"
	// EventAccessedRead notifies when an object is accessed (specifically read).
	EventAccessedRead EventType = "ObjectAccessed:Read"
	// EventAccessedStat notifies when an object is accessed (specifically stat).
	EventAccessedStat EventType = "ObjectAccessed:Stat"
	// EventOther notifies any other events
	EventOther EventType = "ObjectOther"

	// Use unique path separator everywhere
	InternalPathSeparator = "/"

	DefaultEtag = "00000000000000000000000000000000-1"
)

type PathSyncSource

type PathSyncSource interface {
	Endpoint
	Walk(walknFc WalkNodesFunc, pathes ...string) (err error)
	Watch(recursivePath string) (*WatchObject, error)
	ComputeChecksum(node *tree.Node) error
}

func AsPathSyncSource

func AsPathSyncSource(endpoint Endpoint) (PathSyncSource, bool)

type PathSyncTarget

type PathSyncTarget interface {
	Endpoint
	CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)
	UpdateNode(ctx context.Context, node *tree.Node) (err error)
	DeleteNode(ctx context.Context, path string) (err error)
	MoveNode(ctx context.Context, oldPath string, newPath string) (err error)
}

func AsPathSyncTarget

func AsPathSyncTarget(endpoint Endpoint) (PathSyncTarget, bool)

type ProcessorEvent

type ProcessorEvent struct {
	Type string
	Data interface{}
}

type SessionProvider

type SessionProvider interface {
	StartSession(ctx context.Context, rootNode *tree.Node) (*tree.IndexationSession, error)
	FlushSession(ctx context.Context, sessionUuid string) error
	FinishSession(ctx context.Context, sessionUuid string) error
}

func AsSessionProvider

func AsSessionProvider(endpoint Endpoint) (SessionProvider, bool)

type UuidProvider added in v1.0.0

type UuidProvider interface {
	LoadNodeByUuid(ctx context.Context, uuid string) (node *tree.Node, err error)
}

type UuidReceiver added in v1.0.0

type UuidReceiver interface {
	UpdateNodeUuid(ctx context.Context, node *tree.Node) (*tree.Node, error)
}

type Versioner

type Versioner interface {
	Commit(node *tree.Node)
	ListVersions(node *tree.Node) (versions map[int]string, lastVersion int)
}

func AsVersioner

func AsVersioner(endpoint Endpoint) (Versioner, bool)

type WalkNodesFunc

type WalkNodesFunc func(path string, node *tree.Node, err error)

type WatchObject

type WatchObject struct {
	// eventInfo will be put on this chan
	EventInfoChan chan EventInfo
	// errors will be put on this chan
	ErrorChan chan error
	// will stop the watcher goroutines
	DoneChan chan bool
}

func (*WatchObject) Close

func (w *WatchObject) Close()

Close the watcher, will stop all goroutines

func (WatchObject) Done

func (w WatchObject) Done() <-chan bool

Done returns a channel that unblocks when Close has been called

func (*WatchObject) Errors

func (w *WatchObject) Errors() chan error

Errors returns the chan receiving errors

func (*WatchObject) Events

func (w *WatchObject) Events() chan EventInfo

Events returns the chan receiving events

func (WatchObject) NextError

func (w WatchObject) NextError() error

NextError pops the next error from the ErrorChan

func (WatchObject) NextEvent

func (w WatchObject) NextEvent() EventInfo

NextEvent pops the next event from the EventInfoChan

Jump to

Keyboard shortcuts

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