endpoints

package
v1.2.5 Latest Latest
Warning

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

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

Documentation

Overview

Package endpoints provides implementations of various synchronization endpoints Currently supported are FS, S3 and in-memory DB

Index

Constants

This section is empty.

Variables

View Source
var (
	UserAgentAppName = "pydio.sync.client.s3"
	UserAgentVersion = "1.0"
)
View Source
var (
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeAll = []notify.Event{notify.All}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypePut = []notify.Event{notify.Create, notify.Write, notify.Rename}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeCreate = []notify.Event{notify.Create}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeWrite = []notify.Event{notify.Write}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeRename = []notify.Event{notify.Rename}
	// EventTypeDelete contains the notify events that will cause a delete (remove)
	EventTypeDelete = []notify.Event{notify.Remove}
	// EventTypeGet contains the notify events that will cause a get (read)
	EventTypeGet = []notify.Event{} // On macOS, FreeBSD, Solaris this is not available.

)

Functions

func CanonicalPath

func CanonicalPath(path string) string

TODO MOVE IN A fs_windows FILE TO AVOID RUNTIME OS CHECK

func PipeChan

func PipeChan(capacity int) (inputCh chan notify.EventInfo, outputCh chan notify.EventInfo)

PipeChan builds a new dynamically sized channel

Types

type DBEvent

type DBEvent struct {
	Type   string
	Source string
	Target string
}

type FSClient

type FSClient struct {
	RootPath string
	FS       afero.Fs
}

FSClient implementation of an endpoint Implements all Sync interfaces (PathSyncTarget, PathSyncSource, DataSyncTarget and DataSyncSource) Takes a root folder as main parameter Underlying calls to FS are done through Afero.FS virtualization, allowing for mockups and automated testings.

func NewFSClient

func NewFSClient(rootPath string) (*FSClient, error)

func (*FSClient) CreateNode

func (c *FSClient) CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)

func (*FSClient) DeleteNode

func (c *FSClient) DeleteNode(ctx context.Context, path string) (err error)

func (*FSClient) GetEndpointInfo

func (c *FSClient) GetEndpointInfo() common.EndpointInfo

func (*FSClient) GetReaderOn

func (c *FSClient) GetReaderOn(path string) (out io.ReadCloser, err error)

func (*FSClient) GetWriterOn

func (c *FSClient) GetWriterOn(path string, targetSize int64) (out io.WriteCloser, err error)

func (*FSClient) LoadNode

func (c *FSClient) LoadNode(ctx context.Context, path string, leaf ...bool) (node *tree.Node, err error)

LoadNode is the Read in CRUD. leaf bools are used to avoid doing an FS.stat if we already know a node to be a leaf. NOTE : is it useful? Examine later.

func (*FSClient) MoveNode

func (c *FSClient) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)

Move file or folder around.

func (*FSClient) UpdateNode

func (c *FSClient) UpdateNode(ctx context.Context, node *tree.Node) (err error)

func (*FSClient) Walk

func (c *FSClient) Walk(walknFc common.WalkNodesFunc, pathes ...string) (err error)

func (*FSClient) Watch

func (c *FSClient) Watch(recursivePath string) (*common.WatchObject, error)

Watches for all fs events on an input path.

type MemDB

type MemDB struct {
	Nodes []*tree.Node
	// contains filtered or unexported fields
}

func NewMemDB

func NewMemDB() *MemDB

func (*MemDB) CreateNode

func (db *MemDB) CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)

func (*MemDB) DeleteNode

func (db *MemDB) DeleteNode(ctx context.Context, path string) (err error)

func (*MemDB) FindByHash

func (db *MemDB) FindByHash(hash string) (node *tree.Node)

func (*MemDB) FindByUuid

func (db *MemDB) FindByUuid(id string) (node *tree.Node)

func (*MemDB) GetEndpointInfo

func (c *MemDB) GetEndpointInfo() common.EndpointInfo

func (*MemDB) LoadNode

func (db *MemDB) LoadNode(ctx context.Context, path string, leaf ...bool) (node *tree.Node, err error)

***********************

Path Sync Target

***********************

func (*MemDB) MoveNode

func (db *MemDB) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)

func (*MemDB) RegisterEventChannel

func (db *MemDB) RegisterEventChannel(out chan DBEvent)

***********************

Event Emitter

***********************

func (*MemDB) Stats added in v1.2.4

func (db *MemDB) Stats() string

func (*MemDB) String

func (db *MemDB) String() string

func (*MemDB) UpdateNode

func (db *MemDB) UpdateNode(ctx context.Context, node *tree.Node) (err error)

func (*MemDB) Walk

func (db *MemDB) Walk(walknFc common.WalkNodesFunc, pathes ...string) (err error)

***********************

Path Sync Source

***********************

func (*MemDB) Watch

func (db *MemDB) Watch(recursivePath string) (*common.WatchObject, error)

type MockableMinio

type MockableMinio interface {
	StatObject(bucket string, path string, opts minio.StatObjectOptions) (minio.ObjectInfo, error)
	RemoveObject(bucket string, path string) error
	PutObject(bucket string, path string, reader io.Reader, size int64, opts minio.PutObjectOptions) (n int64, err error)
	GetObject(bucket string, path string, opts minio.GetObjectOptions) (object *minio.Object, err error)
	ListObjectsV2(bucketName, objectPrefix string, recursive bool, doneCh <-chan struct{}) <-chan minio.ObjectInfo
	CopyObject(dest minio.DestinationInfo, source minio.SourceInfo) error
	ListenBucketNotification(bucketName, prefix, suffix string, events []string, doneCh <-chan struct{}) <-chan minio.NotificationInfo
}

type S3Client

type S3Client struct {
	Mc                          MockableMinio
	Bucket                      string
	RootPath                    string
	ServerRequiresNormalization bool
	// contains filtered or unexported fields
}

TODO For Minio, add an initialization for detecting empty folders and creating PYDIO_SYNC_HIDDEN_FILE_META

func NewS3Client

func NewS3Client(ctx context.Context, url string, key string, secret string, bucket string, rootPath string) (*S3Client, error)

func (*S3Client) CreateNode

func (c *S3Client) CreateNode(ctx context.Context, node *tree.Node, updateIfExists bool) (err error)

func (*S3Client) DeleteNode

func (c *S3Client) DeleteNode(ctx context.Context, path string) (err error)

func (*S3Client) GetEndpointInfo

func (c *S3Client) GetEndpointInfo() common.EndpointInfo

func (*S3Client) GetReaderOn

func (c *S3Client) GetReaderOn(path string) (out io.ReadCloser, err error)

func (*S3Client) GetWriterOn

func (c *S3Client) GetWriterOn(path string, targetSize int64) (out io.WriteCloser, err error)

func (*S3Client) LoadNode

func (c *S3Client) LoadNode(ctx context.Context, path string, leaf ...bool) (node *tree.Node, err error)

func (*S3Client) MoveNode

func (c *S3Client) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)

func (*S3Client) Stat

func (c *S3Client) Stat(path string) (i os.FileInfo, err error)

func (*S3Client) UpdateNode

func (c *S3Client) UpdateNode(ctx context.Context, node *tree.Node) (err error)

func (*S3Client) UpdateNodeUuid added in v1.0.0

func (c *S3Client) UpdateNodeUuid(ctx context.Context, node *tree.Node) (*tree.Node, error)

UpdateNodeUuid makes this endpoint an UuidReceiver

func (*S3Client) Walk

func (c *S3Client) Walk(walknFc common.WalkNodesFunc, pathes ...string) (err error)

func (*S3Client) Watch

func (c *S3Client) Watch(recursivePath string) (*common.WatchObject, error)

type S3ClientFSWatch

type S3ClientFSWatch struct {
	S3Client
	FSRootPath string
}

func NewS3ClientFSWatch

func NewS3ClientFSWatch(ctx context.Context, url string, key string, secret string, bucket string, rootPath string, fsRootPath string) (*S3ClientFSWatch, error)

func (*S3ClientFSWatch) Watch

func (c *S3ClientFSWatch) Watch(recursivePath string) (*common.WatchObject, error)

type S3FileInfo

type S3FileInfo struct {
	Object minio.ObjectInfo
	// contains filtered or unexported fields
}

func NewS3FileInfo

func NewS3FileInfo(object minio.ObjectInfo) *S3FileInfo

func NewS3FolderInfo

func NewS3FolderInfo(object minio.ObjectInfo) *S3FileInfo

func (*S3FileInfo) IsDir

func (s *S3FileInfo) IsDir() bool

abbreviation for Mode().IsDir()

func (*S3FileInfo) ModTime

func (s *S3FileInfo) ModTime() time.Time

modification time

func (*S3FileInfo) Mode

func (s *S3FileInfo) Mode() os.FileMode

file mode bits

func (*S3FileInfo) Name

func (s *S3FileInfo) Name() string

base name of the file

func (*S3FileInfo) Size

func (s *S3FileInfo) Size() int64

length in bytes for regular files; system-dependent for others

func (*S3FileInfo) Sys

func (s *S3FileInfo) Sys() interface{}

underlying data source (can return nil)

Jump to

Keyboard shortcuts

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