Documentation ¶
Overview ¶
Package model implements repository abstraction and file pulling mechanisms
Index ¶
- Constants
- Variables
- func Rename(from, to string) error
- type ClusterConfigMismatch
- type ConnectionInfo
- type Model
- func (m *Model) AddConnection(rawConn io.Closer, protoConn protocol.Connection)
- func (m *Model) AddRepo(id, dir string, nodes []config.NodeConfiguration)
- func (m *Model) CleanRepos()
- func (m *Model) Close(node string, err error)
- func (m *Model) ClusterConfig(nodeID string, config protocol.ClusterConfigMessage)
- func (m *Model) ConnectedTo(nodeID string) bool
- func (m *Model) ConnectionStats() map[string]ConnectionInfo
- func (m *Model) CurrentGlobalFile(repo string, file string) scanner.File
- func (m *Model) CurrentRepoFile(repo string, file string) scanner.File
- func (m *Model) GlobalSize(repo string) (files, deleted int, bytes int64)
- func (m *Model) Index(nodeID string, repo string, fs []protocol.FileInfo)
- func (m *Model) IndexUpdate(nodeID string, repo string, fs []protocol.FileInfo)
- func (m *Model) LoadIndexes(dir string)
- func (m *Model) LocalSize(repo string) (files, deleted int, bytes int64)
- func (m *Model) NeedFilesRepo(repo string) []scanner.File
- func (m *Model) NeedSize(repo string) (files int, bytes int64)
- func (m *Model) ReplaceLocal(repo string, fs []scanner.File)
- func (m *Model) Request(nodeID, repo, name string, offset int64, size int) ([]byte, error)
- func (m *Model) SaveIndexes(dir string)
- func (m *Model) ScanRepo(repo string) error
- func (m *Model) ScanRepos()
- func (m *Model) SeedLocal(repo string, fs []protocol.FileInfo)
- func (m *Model) StartRepoRO(repo string)
- func (m *Model) StartRepoRW(repo string, threads int)
- func (m *Model) State(repo string) string
Constants ¶
const ( RepoIdle repoState = iota RepoScanning RepoSyncing RepoCleaning )
const (
MaxChangeHistory = 4
)
Variables ¶
var ( ErrNoSuchFile = errors.New("no such file") ErrInvalid = errors.New("file is invalid") )
Functions ¶
Types ¶
type ClusterConfigMismatch ¶ added in v0.8.6
type ClusterConfigMismatch error
type ConnectionInfo ¶
type ConnectionInfo struct { protocol.Statistics Address string ClientVersion string Completion int }
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModel ¶
func NewModel(indexDir string, cfg *config.Configuration, clientName, clientVersion string) *Model
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(rawConn io.Closer, protoConn protocol.Connection)
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) AddRepo ¶ added in v0.8.6
func (m *Model) AddRepo(id, dir string, nodes []config.NodeConfiguration)
func (*Model) CleanRepos ¶ added in v0.8.6
func (m *Model) CleanRepos()
func (*Model) Close ¶
Close removes the peer from the model and closes the underlying connection if possible. Implements the protocol.Model interface.
func (*Model) ClusterConfig ¶ added in v0.8.6
func (m *Model) ClusterConfig(nodeID string, config protocol.ClusterConfigMessage)
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) CurrentGlobalFile ¶ added in v0.8.6
func (*Model) CurrentRepoFile ¶ added in v0.8.6
func (*Model) GlobalSize ¶
GlobalSize returns the number of files, deleted files and total bytes for all files in 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) LoadIndexes ¶ added in v0.8.6
func (*Model) LocalSize ¶
LocalSize returns the number of files, deleted files and total bytes for all files in the local repository.
func (*Model) NeedFilesRepo ¶ added in v0.8.6
NeedFiles returns the list of currently needed files and the total size.
func (*Model) NeedSize ¶ added in v0.8.6
NeedSize returns the number and total size of currently needed files.
func (*Model) ReplaceLocal ¶
ReplaceLocal replaces the local repository index with the given list of files.
func (*Model) Request ¶
Request returns the specified data segment by reading it from local disk. Implements the protocol.Model interface.
func (*Model) SaveIndexes ¶ added in v0.8.6
func (*Model) StartRepoRO ¶ added in v0.8.6
StartRO starts read only processing on the current model. When in read only mode the model will announce files to the cluster but not pull in any external changes.
func (*Model) StartRepoRW ¶ added in v0.8.6
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.