Documentation ¶
Index ¶
- Constants
- Variables
- type Block
- type Connection
- type ConnectionInfo
- type File
- type FileQueue
- func (q *FileQueue) Add(name string, blocks []Block, monitor Monitor)
- func (q *FileQueue) Done(file string, offset int64, data []byte)
- func (q *FileQueue) Get(nodeID string) (queuedBlock, bool)
- func (q *FileQueue) Len() int
- func (q *FileQueue) QueuedFiles() (files []string)
- func (q *FileQueue) RemoveAvailable(toRemove string)
- func (q *FileQueue) SetAvailable(file string, nodes []string)
- type Model
- func (m *Model) AddConnection(rawConn io.Closer, protoConn Connection)
- 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) 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) LimitRate(kbps int)
- func (m *Model) LocalAge() float64
- 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 int64, size uint32, hash []byte) ([]byte, error)
- func (m *Model) SeedLocal(fs []protocol.FileInfo)
- func (m *Model) StartRW(del bool, threads int)
- func (m *Model) Trace(t string)
- func (m *Model) Walk(followSymlinks bool) (files []File, ignore map[string][]string)
- func (m *Model) WhoHas(name string) []string
- type Monitor
Constants ¶
const BlockSize = 128 * 1024
const (
MAX_CHANGE_HISTORY = 4
)
Variables ¶
var ( ErrNoSuchFile = errors.New("no such file") ErrInvalid = errors.New("file is invalid") )
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Connection ¶ added in v0.4.1
type ConnectionInfo ¶
type ConnectionInfo struct { protocol.Statistics Address string ClientID string ClientVersion string }
type FileQueue ¶ added in v0.4.2
type FileQueue struct {
// contains filtered or unexported fields
}
func NewFileQueue ¶ added in v0.4.3
func NewFileQueue() *FileQueue
func (*FileQueue) QueuedFiles ¶ added in v0.4.2
func (*FileQueue) RemoveAvailable ¶ added in v0.4.2
func (*FileQueue) SetAvailable ¶ added in v0.4.2
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
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(rawConn io.Closer, protoConn 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) Close ¶
Close removes the peer from the model and closes the underlying 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) 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. Must be called with the read lock held.
func (*Model) ReplaceLocal ¶
ReplaceLocal replaces the local repository index with the given list of files.
func (*Model) Request ¶
func (m *Model) Request(nodeID, name string, offset int64, 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.
func (*Model) Trace ¶
Trace enables trace logging of the given facility. This is a debugging function; grep for m.trace.