remote

package
v0.0.0-...-be7858c Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package remote implements the client and server side of a scan over a networ. Any connection can be used, as long as it is a stream of bytes (e.g. TCP, SSH).

What follows is a description of the automatically generated documentation for the protobuf messages used over the connection.

Protobuf messages

Package remote is a generated protocol buffer package.

It is generated from these files:

messages.proto

It has these top-level messages:

FileInfo
ScanOptions
ScanProgress
Error
Request
Response

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoClient       = errors.New("remote: this is not a dtsync client")
	ErrNoServer       = errors.New("remote: this is not a dtsync server")
	ErrInvalidId      = errors.New("remote: invalid request ID")
	ErrInvalidPath    = errors.New("remote: invalid path")
	ErrInvalidError   = errors.New("remote: remote sent an invalid error message")
	ErrNoTests        = errors.New("remote: this is not a test tree")
	ErrConcurrentScan = errors.New("remote: Scan() during scan")
)

Errors defined by the remote package.

View Source
var Command_name = map[int32]string{
	0:  "NONE",
	1:  "CLOSE",
	2:  "DATA",
	3:  "SCAN",
	4:  "SCANOPTS",
	5:  "SCANPROG",
	6:  "PUTSTATE",
	10: "MKDIR",
	11: "REMOVE",
	12: "COPY_SRC",
	13: "COPY_DST",
	14: "CREATELINK",
	15: "UPDATELINK",
	16: "READLINK",
	17: "CHMOD",
	18: "RSYNC_SRC",
	19: "RSYNC_DST",
	30: "PUTFILE_TEST",
	31: "INFO",
}
View Source
var Command_value = map[string]int32{
	"NONE":         0,
	"CLOSE":        1,
	"DATA":         2,
	"SCAN":         3,
	"SCANOPTS":     4,
	"SCANPROG":     5,
	"PUTSTATE":     6,
	"MKDIR":        10,
	"REMOVE":       11,
	"COPY_SRC":     12,
	"COPY_DST":     13,
	"CREATELINK":   14,
	"UPDATELINK":   15,
	"READLINK":     16,
	"CHMOD":        17,
	"RSYNC_SRC":    18,
	"RSYNC_DST":    19,
	"PUTFILE_TEST": 30,
	"INFO":         31,
}
View Source
var DataStatus_name = map[int32]string{
	0: "NORMAL",
	1: "FINISH",
	2: "CANCEL",
}
View Source
var DataStatus_value = map[string]int32{
	"NORMAL": 0,
	"FINISH": 1,
	"CANCEL": 2,
}
View Source
var ErrorType_name = map[int32]string{
	0:  "ERR_OTHER",
	1:  "ERR_NOTFOUND",
	2:  "ERR_FOUND",
	3:  "ERR_CHANGED",
	10: "ERR_NO_DIR",
	11: "ERR_NO_REGULAR",
	12: "ERR_NO_SYMLINK",
}
View Source
var ErrorType_value = map[string]int32{
	"ERR_OTHER":      0,
	"ERR_NOTFOUND":   1,
	"ERR_FOUND":      2,
	"ERR_CHANGED":    3,
	"ERR_NO_DIR":     10,
	"ERR_NO_REGULAR": 11,
	"ERR_NO_SYMLINK": 12,
}
View Source
var FileType_name = map[int32]string{
	0: "UNKNOWN",
	1: "REGULAR",
	2: "DIRECTORY",
	3: "SYMLINK",
	4: "NOTFOUND",
}
View Source
var FileType_value = map[string]int32{
	"UNKNOWN":   0,
	"REGULAR":   1,
	"DIRECTORY": 2,
	"SYMLINK":   3,
	"NOTFOUND":  4,
}

Functions

This section is empty.

Types

type Client

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

Client implements the command issuing side of a dtsync connection. Requests may be done in parallel, but they must not affect the same file (or parent directory).

func NewClient

func NewClient(r io.ReadCloser, w io.WriteCloser) (*Client, error)

NewClient writes the connection header and returns a new *Client. It also starts a background goroutine to synchronize requests and responses.

func TestClient

func TestClient() (*Client, error)

TestClient returns a *Client that is already connected to a server where the server has a memory filesystem as backend.

func (*Client) Chmod

func (c *Client) Chmod(target, source tree.FileInfo) (tree.FileInfo, error)

Chmod sends a chmod request to the remote server.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection, terminating the background goroutines.

func (*Client) CopySource

func (c *Client) CopySource(info tree.FileInfo) (io.ReadCloser, error)

func (*Client) CreateDir

func (c *Client) CreateDir(name string, parent, source tree.FileInfo) (tree.FileInfo, error)

func (*Client) CreateFile

func (c *Client) CreateFile(name string, parent, source tree.FileInfo) (tree.Copier, error)
func (c *Client) CreateSymlink(name string, parentInfo, sourceInfo tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)

CreateSymlink creates a new symbolic link on the remote tree.

func (*Client) PutFileTest

func (c *Client) PutFileTest(path []string, contents []byte) (tree.FileInfo, error)

func (*Client) ReadInfo

func (c *Client) ReadInfo(path []string) (tree.FileInfo, error)

ReadInfo returns the FileInfo for the specified file.

func (c *Client) ReadSymlink(file tree.FileInfo) (string, error)

ReadSymlink reads the symlink from the remote tree.

func (*Client) RemoteScan

func (c *Client) RemoteScan(extraOptions *tree.ScanOptions, sendOptions, recvOptions chan *tree.ScanOptions, recvProgress chan<- *tree.ScanProgress, cancel chan struct{}) (io.ReadCloser, error)

RemoteScan runs a remote scan command and returns an io.Reader with the new status file.

func (*Client) Remove

func (c *Client) Remove(file tree.FileInfo) (tree.FileInfo, error)

func (*Client) RsyncDst

func (c *Client) RsyncDst(file, source tree.FileInfo) (io.Reader, tree.Copier, error)

RsyncDst requests a signature from the server and sends a patch file, to update a remote file using the rsync algorithm.

func (*Client) RsyncSrc

func (c *Client) RsyncSrc(file tree.FileInfo, signature io.Reader) (io.ReadCloser, error)

RsyncSrc sends a signature to the server and receives a patch file, to update a local file using the rsync algorithm.

func (*Client) SendStatus

func (c *Client) SendStatus() (tree.Copier, error)

SendStatus creates a Copier that sends status data (encoded as any format, but probably the protobuf serialization), and the remote writes it to a .dtsync file or similar.

func (*Client) String

func (c *Client) String() string

String returns a simple representation for debugging.

func (*Client) UpdateFile

func (c *Client) UpdateFile(file, source tree.FileInfo) (tree.Copier, error)
func (c *Client) UpdateSymlink(file, source tree.FileInfo, contents string) (tree.FileInfo, tree.FileInfo, error)

UpdateSymlink updates a symbolic link on the remote tree to the new path (contents).

type Command

type Command int32
const (
	Command_NONE       Command = 0
	Command_CLOSE      Command = 1
	Command_DATA       Command = 2
	Command_SCAN       Command = 3
	Command_SCANOPTS   Command = 4
	Command_SCANPROG   Command = 5
	Command_PUTSTATE   Command = 6
	Command_MKDIR      Command = 10
	Command_REMOVE     Command = 11
	Command_COPY_SRC   Command = 12
	Command_COPY_DST   Command = 13
	Command_CREATELINK Command = 14
	Command_UPDATELINK Command = 15
	Command_READLINK   Command = 16
	Command_CHMOD      Command = 17
	Command_RSYNC_SRC  Command = 18
	Command_RSYNC_DST  Command = 19
	// testing commands
	Command_PUTFILE_TEST Command = 30
	Command_INFO         Command = 31
)

func (Command) Enum

func (x Command) Enum() *Command

func (Command) EnumDescriptor

func (Command) EnumDescriptor() ([]byte, []int)

func (Command) String

func (x Command) String() string

func (*Command) UnmarshalJSON

func (x *Command) UnmarshalJSON(data []byte) error

type DataStatus

type DataStatus int32
const (
	DataStatus_NORMAL DataStatus = 0
	DataStatus_FINISH DataStatus = 1
	DataStatus_CANCEL DataStatus = 2
)

func (DataStatus) Enum

func (x DataStatus) Enum() *DataStatus

func (DataStatus) EnumDescriptor

func (DataStatus) EnumDescriptor() ([]byte, []int)

func (DataStatus) String

func (x DataStatus) String() string

func (*DataStatus) UnmarshalJSON

func (x *DataStatus) UnmarshalJSON(data []byte) error

type ErrInvalidResponse

type ErrInvalidResponse string

func (ErrInvalidResponse) Error

func (e ErrInvalidResponse) Error() string

type Error

type Error struct {
	Type             *ErrorType `protobuf:"varint,1,opt,name=type,enum=remote.ErrorType" json:"type,omitempty"`
	Message          *string    `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"`
	XXX_unrecognized []byte     `json:"-"`
}

func (*Error) Descriptor

func (*Error) Descriptor() ([]byte, []int)

func (*Error) GetMessage

func (m *Error) GetMessage() string

func (*Error) GetType

func (m *Error) GetType() ErrorType

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) Reset

func (m *Error) Reset()

func (*Error) String

func (m *Error) String() string

type ErrorType

type ErrorType int32
const (
	ErrorType_ERR_OTHER      ErrorType = 0
	ErrorType_ERR_NOTFOUND   ErrorType = 1
	ErrorType_ERR_FOUND      ErrorType = 2
	ErrorType_ERR_CHANGED    ErrorType = 3
	ErrorType_ERR_NO_DIR     ErrorType = 10
	ErrorType_ERR_NO_REGULAR ErrorType = 11
	ErrorType_ERR_NO_SYMLINK ErrorType = 12
)

func (ErrorType) Enum

func (x ErrorType) Enum() *ErrorType

func (ErrorType) EnumDescriptor

func (ErrorType) EnumDescriptor() ([]byte, []int)

func (ErrorType) String

func (x ErrorType) String() string

func (*ErrorType) UnmarshalJSON

func (x *ErrorType) UnmarshalJSON(data []byte) error

type FileInfo

type FileInfo struct {
	Path             []string  `protobuf:"bytes,1,rep,name=path" json:"path,omitempty"`
	Type             *FileType `protobuf:"varint,2,opt,name=type,enum=remote.FileType" json:"type,omitempty"`
	Mode             *uint32   `protobuf:"varint,3,opt,name=mode" json:"mode,omitempty"`
	HasMode          *uint32   `protobuf:"varint,4,opt,name=hasMode" json:"hasMode,omitempty"`
	ModTime          *int64    `protobuf:"zigzag64,5,opt,name=modTime" json:"modTime,omitempty"`
	Size             *int64    `protobuf:"zigzag64,6,opt,name=size" json:"size,omitempty"`
	HashType         *uint32   `protobuf:"varint,7,opt,name=hashType" json:"hashType,omitempty"`
	HashData         []byte    `protobuf:"bytes,8,opt,name=hashData" json:"hashData,omitempty"`
	Inode            *uint64   `protobuf:"varint,9,opt,name=inode" json:"inode,omitempty"`
	XXX_unrecognized []byte    `json:"-"`
}

func (*FileInfo) Descriptor

func (*FileInfo) Descriptor() ([]byte, []int)

func (*FileInfo) GetHasMode

func (m *FileInfo) GetHasMode() uint32

func (*FileInfo) GetHashData

func (m *FileInfo) GetHashData() []byte

func (*FileInfo) GetHashType

func (m *FileInfo) GetHashType() uint32

func (*FileInfo) GetInode

func (m *FileInfo) GetInode() uint64

func (*FileInfo) GetModTime

func (m *FileInfo) GetModTime() int64

func (*FileInfo) GetMode

func (m *FileInfo) GetMode() uint32

func (*FileInfo) GetPath

func (m *FileInfo) GetPath() []string

func (*FileInfo) GetSize

func (m *FileInfo) GetSize() int64

func (*FileInfo) GetType

func (m *FileInfo) GetType() FileType

func (*FileInfo) ProtoMessage

func (*FileInfo) ProtoMessage()

func (*FileInfo) Reset

func (m *FileInfo) Reset()

func (*FileInfo) String

func (m *FileInfo) String() string

type FileType

type FileType int32

See TYPE_* constants in tree/tree.go

const (
	FileType_UNKNOWN   FileType = 0
	FileType_REGULAR   FileType = 1
	FileType_DIRECTORY FileType = 2
	FileType_SYMLINK   FileType = 3
	FileType_NOTFOUND  FileType = 4
)

func (FileType) Enum

func (x FileType) Enum() *FileType

func (FileType) EnumDescriptor

func (FileType) EnumDescriptor() ([]byte, []int)

func (FileType) String

func (x FileType) String() string

func (*FileType) UnmarshalJSON

func (x *FileType) UnmarshalJSON(data []byte) error

type RemoteError

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

func (RemoteError) Error

func (e RemoteError) Error() string

type Request

type Request struct {
	Command          *Command    `protobuf:"varint,1,opt,name=command,enum=remote.Command" json:"command,omitempty"`
	RequestId        *uint64     `protobuf:"varint,2,opt,name=requestId" json:"requestId,omitempty"`
	FileInfo1        *FileInfo   `protobuf:"bytes,3,opt,name=fileInfo1" json:"fileInfo1,omitempty"`
	FileInfo2        *FileInfo   `protobuf:"bytes,4,opt,name=fileInfo2" json:"fileInfo2,omitempty"`
	Name             *string     `protobuf:"bytes,5,opt,name=name" json:"name,omitempty"`
	Data             []byte      `protobuf:"bytes,6,opt,name=data" json:"data,omitempty"`
	Status           *DataStatus `protobuf:"varint,7,opt,name=status,enum=remote.DataStatus" json:"status,omitempty"`
	XXX_unrecognized []byte      `json:"-"`
}

func (*Request) Descriptor

func (*Request) Descriptor() ([]byte, []int)

func (*Request) GetCommand

func (m *Request) GetCommand() Command

func (*Request) GetData

func (m *Request) GetData() []byte

func (*Request) GetFileInfo1

func (m *Request) GetFileInfo1() *FileInfo

func (*Request) GetFileInfo2

func (m *Request) GetFileInfo2() *FileInfo

func (*Request) GetName

func (m *Request) GetName() string

func (*Request) GetRequestId

func (m *Request) GetRequestId() uint64

func (*Request) GetStatus

func (m *Request) GetStatus() DataStatus

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) Reset

func (m *Request) Reset()

func (*Request) String

func (m *Request) String() string

type Response

type Response struct {
	Command          *Command    `protobuf:"varint,1,opt,name=command,enum=remote.Command" json:"command,omitempty"`
	RequestId        *uint64     `protobuf:"varint,2,opt,name=requestId" json:"requestId,omitempty"`
	Error            *Error      `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"`
	FileInfo         *FileInfo   `protobuf:"bytes,4,opt,name=fileInfo" json:"fileInfo,omitempty"`
	ParentInfo       *FileInfo   `protobuf:"bytes,5,opt,name=parentInfo" json:"parentInfo,omitempty"`
	Data             []byte      `protobuf:"bytes,6,opt,name=data" json:"data,omitempty"`
	Status           *DataStatus `protobuf:"varint,7,opt,name=status,enum=remote.DataStatus" json:"status,omitempty"`
	XXX_unrecognized []byte      `json:"-"`
}

func (*Response) Descriptor

func (*Response) Descriptor() ([]byte, []int)

func (*Response) GetCommand

func (m *Response) GetCommand() Command

func (*Response) GetData

func (m *Response) GetData() []byte

func (*Response) GetError

func (m *Response) GetError() *Error

func (*Response) GetFileInfo

func (m *Response) GetFileInfo() *FileInfo

func (*Response) GetParentInfo

func (m *Response) GetParentInfo() *FileInfo

func (*Response) GetRequestId

func (m *Response) GetRequestId() uint64

func (*Response) GetStatus

func (m *Response) GetStatus() DataStatus

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) Reset

func (m *Response) Reset()

func (*Response) String

func (m *Response) String() string

type ScanOptions

type ScanOptions struct {
	Exclude          []string `protobuf:"bytes,1,rep,name=exclude" json:"exclude,omitempty"`
	Include          []string `protobuf:"bytes,2,rep,name=include" json:"include,omitempty"`
	Follow           []string `protobuf:"bytes,3,rep,name=follow" json:"follow,omitempty"`
	Perms            *uint32  `protobuf:"varint,5,opt,name=perms" json:"perms,omitempty"`
	Replica          *string  `protobuf:"bytes,6,opt,name=replica" json:"replica,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*ScanOptions) Descriptor

func (*ScanOptions) Descriptor() ([]byte, []int)

func (*ScanOptions) GetExclude

func (m *ScanOptions) GetExclude() []string

func (*ScanOptions) GetFollow

func (m *ScanOptions) GetFollow() []string

func (*ScanOptions) GetInclude

func (m *ScanOptions) GetInclude() []string

func (*ScanOptions) GetPerms

func (m *ScanOptions) GetPerms() uint32

func (*ScanOptions) GetReplica

func (m *ScanOptions) GetReplica() string

func (*ScanOptions) ProtoMessage

func (*ScanOptions) ProtoMessage()

func (*ScanOptions) Reset

func (m *ScanOptions) Reset()

func (*ScanOptions) String

func (m *ScanOptions) String() string

type ScanProgress

type ScanProgress struct {
	Total            *uint64  `protobuf:"varint,1,opt,name=total" json:"total,omitempty"`
	Done             *uint64  `protobuf:"varint,2,opt,name=done" json:"done,omitempty"`
	Path             []string `protobuf:"bytes,3,rep,name=path" json:"path,omitempty"`
	XXX_unrecognized []byte   `json:"-"`
}

func (*ScanProgress) Descriptor

func (*ScanProgress) Descriptor() ([]byte, []int)

func (*ScanProgress) GetDone

func (m *ScanProgress) GetDone() uint64

func (*ScanProgress) GetPath

func (m *ScanProgress) GetPath() []string

func (*ScanProgress) GetTotal

func (m *ScanProgress) GetTotal() uint64

func (*ScanProgress) ProtoMessage

func (*ScanProgress) ProtoMessage()

func (*ScanProgress) Reset

func (m *ScanProgress) Reset()

func (*ScanProgress) String

func (m *ScanProgress) String() string

type Server

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

Server is an instance of the server side of a dtsync connection. It receives commands and processes them, but does not initiate anything.

func NewServer

func NewServer(r io.ReadCloser, w io.WriteCloser, fs tree.LocalFileTree) *Server

NewServer returns a *Server for the given reader, writer, and filesystem tree. It does not start communication: start .Run() in a separate goroutine for that.

func (*Server) Run

func (s *Server) Run() error

Run runs in a goroutine, until the server experiences a fatal (connection) error. It is used to handle concurrent requests and responses.

Jump to

Keyboard shortcuts

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