Documentation ¶
Index ¶
- Constants
- Variables
- type Block
- type ConnectionInfo
- type File
- type Model
- func (m *Model) AddConnection(conn io.ReadWriteCloser, nodeID string)
- func (m *Model) Close(node string, err error)
- func (m *Model) ConnectedTo(nodeID string) bool
- func (m *Model) ConnectionStats() map[string]ConnectionInfo
- func (m *Model) FilteredWalk(followSymlinks bool) []File
- func (m *Model) Generation() int64
- func (m *Model) GlobalSize() (files, deleted, bytes int)
- func (m *Model) InSyncSize() (files, bytes int)
- func (m *Model) Index(nodeID string, fs []protocol.FileInfo)
- func (m *Model) IndexUpdate(nodeID string, fs []protocol.FileInfo)
- func (m *Model) LocalSize() (files, deleted, bytes int)
- func (m *Model) NeedFiles() (files []File, bytes int)
- func (m *Model) ProtocolIndex() []protocol.FileInfo
- func (m *Model) ReplaceLocal(fs []File)
- func (m *Model) RepoID() string
- func (m *Model) Request(nodeID, name string, offset uint64, size uint32, hash []byte) ([]byte, error)
- func (m *Model) SeedLocal(fs []protocol.FileInfo)
- func (m *Model) StartRW(del bool, pfiles, preqs int)
- func (m *Model) Trace(t string)
- func (m *Model) Walk(followSymlinks bool) (files []File, ignore map[string][]string)
Constants ¶
const BlockSize = 128 * 1024
const (
FlagDeleted = 1 << 12
)
Variables ¶
var ErrNoSuchFile = errors.New("no such file")
Functions ¶
This section is empty.
Types ¶
type Block ¶
type ConnectionInfo ¶
type ConnectionInfo struct { protocol.Statistics Address string }
type Model ¶
func NewModel ¶
NewModel creates and starts a new model. The model starts in read-only mode, where it sends index information to connected peers and responds to requests for file data without altering the local repository in any way.
func (*Model) AddConnection ¶
func (m *Model) AddConnection(conn io.ReadWriteCloser, nodeID string)
AddConnection adds a new peer connection to the model. An initial index will be sent to the connected peer, thereafter index updates whenever the local repository changes.
func (*Model) Close ¶
Close removes the peer from the model and closes the underlyign connection if possible. Implements the protocol.Model interface.
func (*Model) ConnectedTo ¶
ConnectedTo returns true if we are connected to the named node.
func (*Model) ConnectionStats ¶
func (m *Model) ConnectionStats() map[string]ConnectionInfo
ConnectionStats returns a map with connection statistics for each connected node.
func (*Model) FilteredWalk ¶
Walk returns the list of files found in the local repository by scanning the file system. Files are blockwise hashed. Patterns marked in .stignore files are removed from the results.
func (*Model) Generation ¶
Generation returns an opaque integer that is guaranteed to increment on every change to the local repository or global model.
func (*Model) GlobalSize ¶
LocalSize returns the number of files, deleted files and total bytes for all files in the global model.
func (*Model) InSyncSize ¶
InSyncSize returns the number and total byte size of the local files that are in sync with the global model.
func (*Model) Index ¶
Index is called when a new node is connected and we receive their full index. Implements the protocol.Model interface.
func (*Model) IndexUpdate ¶
IndexUpdate is called for incremental updates to connected nodes' indexes. Implements the protocol.Model interface.
func (*Model) LocalSize ¶
LocalSize returns the number of files, deleted files and total bytes for all files in the local repository.
func (*Model) ProtocolIndex ¶
ProtocolIndex returns the current local index in protocol data types.
func (*Model) ReplaceLocal ¶
ReplaceLocal replaces the local repository index with the given list of files. Change suppression is applied to files changing too often.
func (*Model) Request ¶
func (m *Model) Request(nodeID, name string, offset uint64, size uint32, hash []byte) ([]byte, error)
Request returns the specified data segment by reading it from local disk. Implements the protocol.Model interface.
func (*Model) SeedLocal ¶
SeedLocal replaces the local repository index with the given list of files, in protocol data types. Does not track deletes, should only be used to seed the local index from a cache file at startup.
func (*Model) StartRW ¶
StartRW starts read/write processing on the current model. When in read/write mode the model will attempt to keep in sync with the cluster by pulling needed files from peer nodes.