replicat

package module
v0.0.0-...-8d918f7 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2016 License: Apache-2.0 Imports: 23 Imported by: 0

README

Go Report Card

replicat

rsync for the cloud

usage: directory=/tmp/foo go run replicat

Start Replicat with my custom key

  1. Ray: replicat --clusterKey aa88aa88aa88 --directory /tmp/foo

  2. Jacob: replicat --clusterKey aa88aa88aa88 --directory /tmp/foo (this uses machine's hostname:port as the name)

  3. James: replicat --clusterKey aa88aa88aa88 --directory /tmp/foo

// Instances are using tmp folder for testing. Switch to a permanant folder for production or long term use.

Documentation

Overview

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Package replicat is a server for n way synchronization of content (rsync for the cloud). More information at: http://replic.at Copyright 2016 Jacob Taylor jacob@ablox.io License: Apache2 - http://www.apache.org/licenses/LICENSE-2.0

Index

Constants

View Source
const (
	// OWNERSHIP_EXPIRATION_TIMEOUT - Duration for a replicated change to hold ownership after they make changes. This leaves time for multiple filesystem events to come back without being reported to other nodes
	OWNERSHIP_EXPIRATION_TIMEOUT = 5 * time.Second
)
View Source
const (
	// TRACKER_RENAME_TIMEOUT - the amount of time to sleep while waiting for the second event in a rename process
	TRACKER_RENAME_TIMEOUT = time.Millisecond * 25
)

Variables

This section is empty.

Functions

func BootstrapAndServe

func BootstrapAndServe(address string)

BootstrapAndServe - Start the server

func SendEvent

func SendEvent(event Event, fullPath string)

SendEvent gets events that have happened off to the peer servers so they can replicate the same change

func SetGlobalSettings

func SetGlobalSettings(newSettings Settings)

SetGlobalSettings -- set the settings for the replicat server

func WaitFor

func WaitFor(tracker *FilesystemTracker, folder string, waitingFor bool, helper func(tracker *FilesystemTracker, folder string) bool) bool

WaitFor - a helper function that will politely wait until the helper argument function evaluates to the value of waitingFor. this is great for waiting for the tracker to catch up to the filesystem in tests, for example.

Types

type ChangeHandler

type ChangeHandler interface {
	FolderCreated(name string) (err error)
	FolderDeleted(name string) (err error)
	FolderUpdated(name string) (err error)
	FileCreated(name string) (err error)
	FileDeleted(name string) (err error)
	FileUpdated(name string) (err error)
}

ChangeHandler - Listener for tracking changes that happen to a storage system

type DirTreeMap

type DirTreeMap map[string][]string

DirTreeMap is a mapping between directories and lists of file names.

func (DirTreeMap) Clone

func (orig DirTreeMap) Clone() (clone DirTreeMap)

Clone a DirTreeMap

type Entry

type Entry struct {
	os.FileInfo
	// contains filtered or unexported fields
}

Entry - contains the data for a file

func NewDirectory

func NewDirectory() *Entry

NewDirectory - creates and returns a new Directory

func NewDirectoryFromFileInfo

func NewDirectoryFromFileInfo(info *os.FileInfo) *Entry

NewDirectoryFromFileInfo - creates and returns a new Directory based on a fileinfo structure

type Event

type Event struct {
	Source        string
	Name          string
	Path          string
	SourcePath    string
	Time          time.Time
	IsDirectory   bool
	NetworkSource string
}

Event stores the relevant information on events or updates to the storage layer.

type FilesystemTracker

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

FilesystemTracker - Track a filesystem and keep it in sync

func (*FilesystemTracker) CreatePath

func (handler *FilesystemTracker) CreatePath(pathName string, isDirectory bool) (err error)

CreatePath tells the storage tracker to create a new path

func (*FilesystemTracker) DeleteFolder

func (handler *FilesystemTracker) DeleteFolder(name string) error

DeleteFolder - This storage handler should remove the specified path

func (*FilesystemTracker) ListFolders

func (handler *FilesystemTracker) ListFolders() (folderList []string)

ListFolders - This storage handler should return a list of contained folders.

func (*FilesystemTracker) Rename

func (handler *FilesystemTracker) Rename(sourcePath string, destinationPath string, isDirectory bool) (err error)

Rename - Rename a file or folder from one location to another

type LogOnlyChangeHandler

type LogOnlyChangeHandler struct {
}

LogOnlyChangeHandler - sample change handler

func (*LogOnlyChangeHandler) FileCreated

func (handler *LogOnlyChangeHandler) FileCreated(name string) error

FileCreated - track a new folder being created

func (*LogOnlyChangeHandler) FileDeleted

func (handler *LogOnlyChangeHandler) FileDeleted(name string) error

FileDeleted - track a new folder being deleted

func (*LogOnlyChangeHandler) FileUpdated

func (handler *LogOnlyChangeHandler) FileUpdated(name string) error

FileUpdated - track a folder being updated

func (*LogOnlyChangeHandler) FolderCreated

func (handler *LogOnlyChangeHandler) FolderCreated(name string) error

FolderCreated - track a new folder being created

func (*LogOnlyChangeHandler) FolderDeleted

func (handler *LogOnlyChangeHandler) FolderDeleted(name string) error

FolderDeleted - track a new folder being deleted

func (*LogOnlyChangeHandler) FolderUpdated

func (handler *LogOnlyChangeHandler) FolderUpdated(name string) error

FolderUpdated - track a folder being updated

type Node

type Node struct {
	Directory string
	Address   string
}

Node Details for a single replicat node

type ReplicatServer

type ReplicatServer struct {
	ClusterKey    string
	Name          string
	Address       string
	CurrentState  DirTreeMap
	PreviousState DirTreeMap
	Lock          sync.Mutex
	// contains filtered or unexported fields
}

ReplicatServer is a structure that contains the definition of the servers in a cluster. Each node has a name and this node (as determined by globalSettings.name at the moment) also has a StorageTracker interface.

type Settings

type Settings struct {
	Name               string
	ManagerAddress     string
	ManagerCredentials string
	ClusterKey         string
	Nodes              map[string]Node
}

Settings - for the server. including a map of the nodes

func GetGlobalSettings

func GetGlobalSettings() Settings

GetGlobalSettings -- retrieve the settings for the replicat server

type StorageTracker

type StorageTracker interface {
	CreatePath(relativePath string, isDirectory bool) (err error)
	Rename(sourcePath string, destinationPath string, isDirectory bool) (err error)
	DeleteFolder(name string) (err error)
	ListFolders() (folderList []string)
}

StorageTracker - Listener that allows you to tell the tracker what has happened elsewhere so it can mirror the changes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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