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 ¶
- Variables
- type Client
- func (c *Client) Chmod(target, source tree.FileInfo) (tree.FileInfo, error)
- func (c *Client) Close() error
- func (c *Client) CopySource(info tree.FileInfo) (io.ReadCloser, error)
- func (c *Client) CreateDir(name string, parent, source tree.FileInfo) (tree.FileInfo, error)
- 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)
- func (c *Client) PutFileTest(path []string, contents []byte) (tree.FileInfo, error)
- func (c *Client) ReadInfo(path []string) (tree.FileInfo, error)
- func (c *Client) ReadSymlink(file tree.FileInfo) (string, error)
- func (c *Client) RemoteScan(extraOptions *tree.ScanOptions, ...) (io.ReadCloser, error)
- func (c *Client) Remove(file tree.FileInfo) (tree.FileInfo, error)
- func (c *Client) RsyncDst(file, source tree.FileInfo) (io.Reader, tree.Copier, error)
- func (c *Client) RsyncSrc(file tree.FileInfo, signature io.Reader) (io.ReadCloser, error)
- func (c *Client) SendStatus() (tree.Copier, error)
- func (c *Client) String() string
- 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)
- type Command
- type DataStatus
- type ErrInvalidResponse
- type Error
- type ErrorType
- type FileInfo
- func (*FileInfo) Descriptor() ([]byte, []int)
- func (m *FileInfo) GetHasMode() uint32
- func (m *FileInfo) GetHashData() []byte
- func (m *FileInfo) GetHashType() uint32
- func (m *FileInfo) GetInode() uint64
- func (m *FileInfo) GetModTime() int64
- func (m *FileInfo) GetMode() uint32
- func (m *FileInfo) GetPath() []string
- func (m *FileInfo) GetSize() int64
- func (m *FileInfo) GetType() FileType
- func (*FileInfo) ProtoMessage()
- func (m *FileInfo) Reset()
- func (m *FileInfo) String() string
- type FileType
- type RemoteError
- type Request
- func (*Request) Descriptor() ([]byte, []int)
- func (m *Request) GetCommand() Command
- func (m *Request) GetData() []byte
- func (m *Request) GetFileInfo1() *FileInfo
- func (m *Request) GetFileInfo2() *FileInfo
- func (m *Request) GetName() string
- func (m *Request) GetRequestId() uint64
- func (m *Request) GetStatus() DataStatus
- func (*Request) ProtoMessage()
- func (m *Request) Reset()
- func (m *Request) String() string
- type Response
- func (*Response) Descriptor() ([]byte, []int)
- func (m *Response) GetCommand() Command
- func (m *Response) GetData() []byte
- func (m *Response) GetError() *Error
- func (m *Response) GetFileInfo() *FileInfo
- func (m *Response) GetParentInfo() *FileInfo
- func (m *Response) GetRequestId() uint64
- func (m *Response) GetStatus() DataStatus
- func (*Response) ProtoMessage()
- func (m *Response) Reset()
- func (m *Response) String() string
- type ScanOptions
- func (*ScanOptions) Descriptor() ([]byte, []int)
- func (m *ScanOptions) GetExclude() []string
- func (m *ScanOptions) GetFollow() []string
- func (m *ScanOptions) GetInclude() []string
- func (m *ScanOptions) GetPerms() uint32
- func (m *ScanOptions) GetReplica() string
- func (*ScanOptions) ProtoMessage()
- func (m *ScanOptions) Reset()
- func (m *ScanOptions) String() string
- type ScanProgress
- type Server
Constants ¶
This section is empty.
Variables ¶
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.
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",
}
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,
}
var DataStatus_name = map[int32]string{
0: "NORMAL",
1: "FINISH",
2: "CANCEL",
}
var DataStatus_value = map[string]int32{
"NORMAL": 0,
"FINISH": 1,
"CANCEL": 2,
}
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",
}
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,
}
var FileType_name = map[int32]string{
0: "UNKNOWN",
1: "REGULAR",
2: "DIRECTORY",
3: "SYMLINK",
4: "NOTFOUND",
}
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 ¶
TestClient returns a *Client that is already connected to a server where the server has a memory filesystem as backend.
func (*Client) CopySource ¶
func (*Client) CreateFile ¶
func (*Client) CreateSymlink ¶
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 (*Client) ReadSymlink ¶
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) RsyncDst ¶
RsyncDst requests a signature from the server and sends a patch file, to update a remote file using the rsync algorithm.
func (*Client) RsyncSrc ¶
RsyncSrc sends a signature to the server and receives a patch file, to update a local file using the rsync algorithm.
func (*Client) SendStatus ¶
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) UpdateFile ¶
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) EnumDescriptor ¶
func (*Command) UnmarshalJSON ¶
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) GetMessage ¶
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
type ErrorType ¶
type ErrorType int32
func (ErrorType) EnumDescriptor ¶
func (*ErrorType) UnmarshalJSON ¶
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) GetHasMode ¶
func (*FileInfo) GetHashData ¶
func (*FileInfo) GetHashType ¶
func (*FileInfo) GetModTime ¶
func (*FileInfo) ProtoMessage ¶
func (*FileInfo) ProtoMessage()
type FileType ¶
type FileType int32
See TYPE_* constants in tree/tree.go
func (FileType) EnumDescriptor ¶
func (*FileType) UnmarshalJSON ¶
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) GetCommand ¶
func (*Request) GetFileInfo1 ¶
func (*Request) GetFileInfo2 ¶
func (*Request) GetRequestId ¶
func (*Request) GetStatus ¶
func (m *Request) GetStatus() DataStatus
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
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) GetCommand ¶
func (*Response) GetFileInfo ¶
func (*Response) GetParentInfo ¶
func (*Response) GetRequestId ¶
func (*Response) GetStatus ¶
func (m *Response) GetStatus() DataStatus
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
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.