Back to godoc.org

Package endpoints

v1.6.1
Latest Go to latest

The latest major version is .

Published: Jul 9, 2019 | License: AGPL-3.0 | Module: github.com/EngineerIG/cells

Overview

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

Index

Variables

var (
	UserAgentAppName = "pydio.sync.client.s3"
	UserAgentVersion = "1.0"
)
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.

)

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

type DBEvent

type DBEvent struct {
	Type   string
	Source string
	Target string
}

type Discarder

type Discarder struct {
	bytes.Buffer
}

func (*Discarder) Close

func (d *Discarder) Close() error

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) ComputeChecksum

func (c *FSClient) ComputeChecksum(node *tree.Node) 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) ComputeChecksum

func (db *MemDB) ComputeChecksum(node *tree.Node) error

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

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) ComputeChecksum

func (c *S3Client) ComputeChecksum(node *tree.Node) 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) SetPlainSizeComputer

func (c *S3Client) SetPlainSizeComputer(computer func(nodeUUID string) (int64, 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

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)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier