Documentation
¶
Overview ¶
Package persistent is a generated GoMock package.
Package persistent is a generated GoMock package.
Package persistent is a generated GoMock package.
Package persistent is a generated GoMock package.
Index ¶
- Constants
- type Build
- type CPU
- type CPUTimes
- type Disk
- type Host
- type HostManager
- type Memory
- type MockHostManager
- func (m *MockHostManager) Delete(arg0 context.Context, arg1 string) error
- func (m *MockHostManager) EXPECT() *MockHostManagerMockRecorder
- func (m *MockHostManager) Load(arg0 context.Context, arg1 string) (*Host, bool)
- func (m *MockHostManager) LoadAll(arg0 context.Context) ([]*Host, error)
- func (m *MockHostManager) LoadRandom(arg0 context.Context, arg1 int, arg2 set.SafeSet[string]) ([]*Host, error)
- func (m *MockHostManager) RunGC(arg0 context.Context) error
- func (m *MockHostManager) Store(arg0 context.Context, arg1 *Host) error
- type MockHostManagerMockRecorder
- func (mr *MockHostManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) LoadRandom(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) RunGC(arg0 any) *gomock.Call
- func (mr *MockHostManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call
- type MockPeerManager
- func (m *MockPeerManager) Delete(arg0 context.Context, arg1 string) error
- func (m *MockPeerManager) DeleteAllByHostID(arg0 context.Context, arg1 string) error
- func (m *MockPeerManager) DeleteAllByTaskID(arg0 context.Context, arg1 string) error
- func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder
- func (m *MockPeerManager) Load(arg0 context.Context, arg1 string) (*Peer, bool)
- func (m *MockPeerManager) LoadAll(arg0 context.Context) ([]*Peer, error)
- func (m *MockPeerManager) LoadAllByHostID(arg0 context.Context, arg1 string) ([]*Peer, error)
- func (m *MockPeerManager) LoadAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)
- func (m *MockPeerManager) LoadAllIDsByHostID(arg0 context.Context, arg1 string) ([]string, error)
- func (m *MockPeerManager) LoadAllIDsByTaskID(arg0 context.Context, arg1 string) ([]string, error)
- func (m *MockPeerManager) LoadPersistentAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)
- func (m *MockPeerManager) Store(arg0 context.Context, arg1 *Peer) error
- type MockPeerManagerMockRecorder
- func (mr *MockPeerManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) DeleteAllByHostID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) DeleteAllByTaskID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadAllByHostID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadAllByTaskID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadAllIDsByHostID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadAllIDsByTaskID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) LoadPersistentAllByTaskID(arg0, arg1 any) *gomock.Call
- func (mr *MockPeerManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call
- type MockResource
- type MockResourceMockRecorder
- type MockTaskManager
- func (m *MockTaskManager) Delete(arg0 context.Context, arg1 string) error
- func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
- func (m *MockTaskManager) Load(arg0 context.Context, arg1 string) (*Task, bool)
- func (m *MockTaskManager) LoadAll(arg0 context.Context) ([]*Task, error)
- func (m *MockTaskManager) LoadCurrentPersistentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)
- func (m *MockTaskManager) LoadCurrentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)
- func (m *MockTaskManager) Store(arg0 context.Context, arg1 *Task) error
- type MockTaskManagerMockRecorder
- func (mr *MockTaskManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount(arg0, arg1 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) LoadCurrentReplicaCount(arg0, arg1 any) *gomock.Call
- func (mr *MockTaskManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call
- type Network
- type Peer
- type PeerManager
- type PeerOption
- type Resource
- type Task
- type TaskManager
Constants ¶
const ( // Peer has been created but did not start running. PeerStatePending = "Pending" // Peer is uploading resources for p2p cluster. PeerStateUploading = "Uploading" // Peer successfully registered as empty scope size. PeerStateReceivedEmpty = "ReceivedEmpty" // Peer successfully registered as normal scope size. PeerStateReceivedNormal = "ReceivedNormal" // Peer is downloading resources from peer. PeerStateRunning = "Running" // Peer has been downloaded successfully. PeerStateSucceeded = "Succeeded" // Peer has been downloaded failed. PeerStateFailed = "Failed" )
const ( // Peer is uploding. PeerEventUpload = "Upload" // Peer is registered as empty scope size. PeerEventRegisterEmpty = "RegisterEmpty" // Peer is registered as normal scope size. PeerEventRegisterNormal = "RegisterNormal" // Peer is downloading. PeerEventDownload = "Download" // Peer downloaded or uploaded successfully. PeerEventSucceeded = "Succeeded" // Peer downloaded or uploaded failed. PeerEventFailed = "Failed" )
const ( // Tiny file size is 128 bytes. TinyFileSize = 128 // Empty file size is 0 bytes. EmptyFileSize = 0 )
const ( // Task has been created but did not start uploading. TaskStatePending = "Pending" // Task is uploading resources for p2p cluster. TaskStateUploading = "Uploading" // Task has been uploaded successfully. TaskStateSucceeded = "Succeeded" // Task has been uploaded failed. TaskStateFailed = "Failed" )
const ( // Task is uploading. TaskEventUpload = "Upload" // Task uploaded successfully. TaskEventSucceeded = "Succeeded" // Task uploaded failed. TaskEventFailed = "Failed" )
const (
// GC persistent host id.
GCHostID = "persistent-host"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Build struct {
// Git version.
GitVersion string
// Git commit.
GitCommit string
// Golang version.
GoVersion string
// Rust version.
RustVersion string
// Build platform.
Platform string
}
Build contains content for build.
type CPU ¶
type CPU struct {
// Number of logical cores in the system.
LogicalCount uint32
// Number of physical cores in the system.
PhysicalCount uint32
// Percent calculates the percentage of cpu used.
Percent float64
// Calculates the percentage of cpu used by process.
ProcessPercent float64
// Times contains the amounts of time the CPU has spent performing different kinds of work.
Times CPUTimes
}
CPU contains content for cpu.
type CPUTimes ¶
type CPUTimes struct {
// CPU time of user.
User float64
// CPU time of system.
System float64
// CPU time of idle.
Idle float64
// CPU time of nice.
Nice float64
// CPU time of iowait.
Iowait float64
// CPU time of irq.
Irq float64
// CPU time of softirq.
Softirq float64
// CPU time of steal.
Steal float64
// CPU time of guest.
Guest float64
// CPU time of guest nice.
GuestNice float64
}
CPUTimes contains content for cpu times.
type Disk ¶
type Disk struct {
// Total amount of disk on the data path of dragonfly.
Total uint64
// Free amount of disk on the data path of dragonfly.
Free uint64
// Used amount of disk on the data path of dragonfly.
Used uint64
// Used percent of disk on the data path of dragonfly directory.
UsedPercent float64
// Total amount of indoes on the data path of dragonfly directory.
InodesTotal uint64
// Used amount of indoes on the data path of dragonfly directory.
InodesUsed uint64
// Free amount of indoes on the data path of dragonfly directory.
InodesFree uint64
// Used percent of indoes on the data path of dragonfly directory.
InodesUsedPercent float64
// Disk write bandwidth, unit is byte/s.
WriteBandwidth uint64
// Disk read bandwidth, unit is byte/s.
ReadBandwidth uint64
}
Disk contains content for disk.
type Host ¶
type Host struct {
// ID is host id.
ID string
// Type is host type.
Type types.HostType
// Name is the instance name.
Name string
// Hostname is host name.
Hostname string
// IP is host ip.
IP string
// Port is grpc service port.
Port int32
// DownloadPort is piece downloading port.
DownloadPort int32
// ProxyPort is the proxy server port.
ProxyPort int32
// shared with other peers.
DisableShared bool
// Host OS.
OS string
// Host platform.
Platform string
// Host platform family.
PlatformFamily string
// Host platform version.
PlatformVersion string
// Host kernel version.
KernelVersion string
// CPU Stat.
CPU CPU
// Memory Stat.
Memory Memory
// Network Stat.
Network Network
// Dist Stat.
Disk Disk
// Build information.
Build Build
// SchedulerClusterID is the scheduler cluster id matched by scopes.
SchedulerClusterID uint64
// AnnounceInterval is the interval between host announces to scheduler.
AnnounceInterval time.Duration
// CreatedAt is host create time.
CreatedAt time.Time
// UpdatedAt is host update time.
UpdatedAt time.Time
// Host log.
Log *logger.SugaredLoggerOnWith
}
Host contains content for host.
func NewHost ¶
func NewHost( id, name, hostname, ip, os, platform, platformFamily, platformVersion, kernelVersion string, port, downloadPort, proxyPort int32, schedulerClusterId uint64, disableShared bool, typ types.HostType, cpu CPU, memory Memory, network Network, disk Disk, build Build, announceInterval time.Duration, createdAt, updatedAt time.Time, log *logger.SugaredLoggerOnWith, ) *Host
NewHost returns a new host.
type HostManager ¶
type HostManager interface {
// Load returns host by a key.
Load(context.Context, string) (*Host, bool)
// Store sets host.
Store(context.Context, *Host) error
// Delete deletes host by a key.
Delete(context.Context, string) error
// LoadAll returns all hosts.
LoadAll(context.Context) ([]*Host, error)
// LoadRandom loads host randomly through the set of redis.
LoadRandom(context.Context, int, set.SafeSet[string]) ([]*Host, error)
// RunGC runs garbage collection.
RunGC(context.Context) error
}
HostManager is the interface used for host manager.
type Memory ¶
type Memory struct {
// Total amount of RAM on this system.
Total uint64
// RAM available for programs to allocate.
Available uint64
// RAM used by programs.
Used uint64
// Percentage of RAM used by programs.
UsedPercent float64
// Calculates the percentage of memory used by process.
ProcessUsedPercent float64
// This is the kernel's notion of free memory.
Free uint64
}
Memory contains content for memory.
type MockHostManager ¶
type MockHostManager struct {
// contains filtered or unexported fields
}
MockHostManager is a mock of HostManager interface.
func NewMockHostManager ¶
func NewMockHostManager(ctrl *gomock.Controller) *MockHostManager
NewMockHostManager creates a new mock instance.
func (*MockHostManager) Delete ¶
func (m *MockHostManager) Delete(arg0 context.Context, arg1 string) error
Delete mocks base method.
func (*MockHostManager) EXPECT ¶
func (m *MockHostManager) EXPECT() *MockHostManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockHostManager) LoadAll ¶
func (m *MockHostManager) LoadAll(arg0 context.Context) ([]*Host, error)
LoadAll mocks base method.
func (*MockHostManager) LoadRandom ¶
func (m *MockHostManager) LoadRandom(arg0 context.Context, arg1 int, arg2 set.SafeSet[string]) ([]*Host, error)
LoadRandom mocks base method.
type MockHostManagerMockRecorder ¶
type MockHostManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockHostManagerMockRecorder is the mock recorder for MockHostManager.
func (*MockHostManagerMockRecorder) Delete ¶
func (mr *MockHostManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockHostManagerMockRecorder) Load ¶
func (mr *MockHostManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockHostManagerMockRecorder) LoadAll ¶
func (mr *MockHostManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
LoadAll indicates an expected call of LoadAll.
func (*MockHostManagerMockRecorder) LoadRandom ¶
func (mr *MockHostManagerMockRecorder) LoadRandom(arg0, arg1, arg2 any) *gomock.Call
LoadRandom indicates an expected call of LoadRandom.
type MockPeerManager ¶
type MockPeerManager struct {
// contains filtered or unexported fields
}
MockPeerManager is a mock of PeerManager interface.
func NewMockPeerManager ¶
func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager
NewMockPeerManager creates a new mock instance.
func (*MockPeerManager) Delete ¶
func (m *MockPeerManager) Delete(arg0 context.Context, arg1 string) error
Delete mocks base method.
func (*MockPeerManager) DeleteAllByHostID ¶
func (m *MockPeerManager) DeleteAllByHostID(arg0 context.Context, arg1 string) error
DeleteAllByHostID mocks base method.
func (*MockPeerManager) DeleteAllByTaskID ¶
func (m *MockPeerManager) DeleteAllByTaskID(arg0 context.Context, arg1 string) error
DeleteAllByTaskID mocks base method.
func (*MockPeerManager) EXPECT ¶
func (m *MockPeerManager) EXPECT() *MockPeerManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPeerManager) LoadAll ¶
func (m *MockPeerManager) LoadAll(arg0 context.Context) ([]*Peer, error)
LoadAll mocks base method.
func (*MockPeerManager) LoadAllByHostID ¶
LoadAllByHostID mocks base method.
func (*MockPeerManager) LoadAllByTaskID ¶
LoadAllByTaskID mocks base method.
func (*MockPeerManager) LoadAllIDsByHostID ¶
LoadAllIDsByHostID mocks base method.
func (*MockPeerManager) LoadAllIDsByTaskID ¶
LoadAllIDsByTaskID mocks base method.
func (*MockPeerManager) LoadPersistentAllByTaskID ¶
func (m *MockPeerManager) LoadPersistentAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)
LoadPersistentAllByTaskID mocks base method.
type MockPeerManagerMockRecorder ¶
type MockPeerManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockPeerManagerMockRecorder is the mock recorder for MockPeerManager.
func (*MockPeerManagerMockRecorder) Delete ¶
func (mr *MockPeerManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockPeerManagerMockRecorder) DeleteAllByHostID ¶
func (mr *MockPeerManagerMockRecorder) DeleteAllByHostID(arg0, arg1 any) *gomock.Call
DeleteAllByHostID indicates an expected call of DeleteAllByHostID.
func (*MockPeerManagerMockRecorder) DeleteAllByTaskID ¶
func (mr *MockPeerManagerMockRecorder) DeleteAllByTaskID(arg0, arg1 any) *gomock.Call
DeleteAllByTaskID indicates an expected call of DeleteAllByTaskID.
func (*MockPeerManagerMockRecorder) Load ¶
func (mr *MockPeerManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockPeerManagerMockRecorder) LoadAll ¶
func (mr *MockPeerManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
LoadAll indicates an expected call of LoadAll.
func (*MockPeerManagerMockRecorder) LoadAllByHostID ¶
func (mr *MockPeerManagerMockRecorder) LoadAllByHostID(arg0, arg1 any) *gomock.Call
LoadAllByHostID indicates an expected call of LoadAllByHostID.
func (*MockPeerManagerMockRecorder) LoadAllByTaskID ¶
func (mr *MockPeerManagerMockRecorder) LoadAllByTaskID(arg0, arg1 any) *gomock.Call
LoadAllByTaskID indicates an expected call of LoadAllByTaskID.
func (*MockPeerManagerMockRecorder) LoadAllIDsByHostID ¶
func (mr *MockPeerManagerMockRecorder) LoadAllIDsByHostID(arg0, arg1 any) *gomock.Call
LoadAllIDsByHostID indicates an expected call of LoadAllIDsByHostID.
func (*MockPeerManagerMockRecorder) LoadAllIDsByTaskID ¶
func (mr *MockPeerManagerMockRecorder) LoadAllIDsByTaskID(arg0, arg1 any) *gomock.Call
LoadAllIDsByTaskID indicates an expected call of LoadAllIDsByTaskID.
func (*MockPeerManagerMockRecorder) LoadPersistentAllByTaskID ¶
func (mr *MockPeerManagerMockRecorder) LoadPersistentAllByTaskID(arg0, arg1 any) *gomock.Call
LoadPersistentAllByTaskID indicates an expected call of LoadPersistentAllByTaskID.
type MockResource ¶
type MockResource struct {
// contains filtered or unexported fields
}
MockResource is a mock of Resource interface.
func NewMockResource ¶
func NewMockResource(ctrl *gomock.Controller) *MockResource
NewMockResource creates a new mock instance.
func (*MockResource) EXPECT ¶
func (m *MockResource) EXPECT() *MockResourceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockResource) HostManager ¶
func (m *MockResource) HostManager() HostManager
HostManager mocks base method.
func (*MockResource) PeerManager ¶
func (m *MockResource) PeerManager() PeerManager
PeerManager mocks base method.
func (*MockResource) TaskManager ¶
func (m *MockResource) TaskManager() TaskManager
TaskManager mocks base method.
type MockResourceMockRecorder ¶
type MockResourceMockRecorder struct {
// contains filtered or unexported fields
}
MockResourceMockRecorder is the mock recorder for MockResource.
func (*MockResourceMockRecorder) HostManager ¶
func (mr *MockResourceMockRecorder) HostManager() *gomock.Call
HostManager indicates an expected call of HostManager.
func (*MockResourceMockRecorder) PeerManager ¶
func (mr *MockResourceMockRecorder) PeerManager() *gomock.Call
PeerManager indicates an expected call of PeerManager.
func (*MockResourceMockRecorder) TaskManager ¶
func (mr *MockResourceMockRecorder) TaskManager() *gomock.Call
TaskManager indicates an expected call of TaskManager.
type MockTaskManager ¶
type MockTaskManager struct {
// contains filtered or unexported fields
}
MockTaskManager is a mock of TaskManager interface.
func NewMockTaskManager ¶
func NewMockTaskManager(ctrl *gomock.Controller) *MockTaskManager
NewMockTaskManager creates a new mock instance.
func (*MockTaskManager) Delete ¶
func (m *MockTaskManager) Delete(arg0 context.Context, arg1 string) error
Delete mocks base method.
func (*MockTaskManager) EXPECT ¶
func (m *MockTaskManager) EXPECT() *MockTaskManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTaskManager) LoadAll ¶
func (m *MockTaskManager) LoadAll(arg0 context.Context) ([]*Task, error)
LoadAll mocks base method.
func (*MockTaskManager) LoadCurrentPersistentReplicaCount ¶
func (m *MockTaskManager) LoadCurrentPersistentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)
LoadCurrentPersistentReplicaCount mocks base method.
func (*MockTaskManager) LoadCurrentReplicaCount ¶
func (m *MockTaskManager) LoadCurrentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)
LoadCurrentReplicaCount mocks base method.
type MockTaskManagerMockRecorder ¶
type MockTaskManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskManagerMockRecorder is the mock recorder for MockTaskManager.
func (*MockTaskManagerMockRecorder) Delete ¶
func (mr *MockTaskManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call
Delete indicates an expected call of Delete.
func (*MockTaskManagerMockRecorder) Load ¶
func (mr *MockTaskManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call
Load indicates an expected call of Load.
func (*MockTaskManagerMockRecorder) LoadAll ¶
func (mr *MockTaskManagerMockRecorder) LoadAll(arg0 any) *gomock.Call
LoadAll indicates an expected call of LoadAll.
func (*MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount ¶
func (mr *MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount(arg0, arg1 any) *gomock.Call
LoadCurrentPersistentReplicaCount indicates an expected call of LoadCurrentPersistentReplicaCount.
func (*MockTaskManagerMockRecorder) LoadCurrentReplicaCount ¶
func (mr *MockTaskManagerMockRecorder) LoadCurrentReplicaCount(arg0, arg1 any) *gomock.Call
LoadCurrentReplicaCount indicates an expected call of LoadCurrentReplicaCount.
type Network ¶
type Network struct {
// Return count of tcp connections opened and status is ESTABLISHED.
TCPConnectionCount uint32
// Return count of upload tcp connections opened and status is ESTABLISHED.
UploadTCPConnectionCount uint32
// Location path(area|country|province|city|...).
Location string
// IDC where the peer host is located
IDC string
// RxBandwidth of the host, unit is byte/s.
RxBandwidth uint64
// MaxRxBandwidth of the host, unit is byte/s.
MaxRxBandwidth uint64
// TxBandwidth of the host, unit is byte/s.
TxBandwidth uint64
// MaxTxBandwidth of the host, unit is byte/s.
MaxTxBandwidth uint64
}
Network contains content for network.
type Peer ¶
type Peer struct {
// ID is persistent peer id.
ID string
// Persistent is whether the peer is persistent.
Persistent bool
// ConcurrentPieceCount is the count of pieces that can be downloaded concurrently.
ConcurrentPieceCount uint32
// Pieces is finished pieces bitset.
FinishedPieces *bitset.BitSet
// Persistent peer state machine.
FSM *fsm.FSM
// Task is persistent task.
Task *Task
// Host is the peer host.
Host *Host
// BlockParents is bad parents ids.
BlockParents []string
// Cost is the cost of downloading.
Cost time.Duration
// CreatedAt is persistent peer create time.
CreatedAt time.Time
// UpdatedAt is persistent peer update time.
UpdatedAt time.Time
// Persistent peer log.
Log *logger.SugaredLoggerOnWith
}
Peer contains content for persistent peer.
type PeerManager ¶
type PeerManager interface {
// Load returns peer by a key.
Load(context.Context, string) (*Peer, bool)
// Store sets peer.
Store(context.Context, *Peer) error
// Delete deletes peer by a key.
Delete(context.Context, string) error
// LoadAll returns all peers.
LoadAll(context.Context) ([]*Peer, error)
// LoadAllByTaskID returns all peers by task id.
LoadAllByTaskID(context.Context, string) ([]*Peer, error)
// LoadAllIDsByTaskID returns all peer ids by task id.
LoadAllIDsByTaskID(context.Context, string) ([]string, error)
// LoadPersistentAllByTaskID returns all persistent peers by task id.
LoadPersistentAllByTaskID(context.Context, string) ([]*Peer, error)
// DeleteAllByTaskID deletes all peers by task id.
DeleteAllByTaskID(context.Context, string) error
// LoadAllByHostID returns all peers by host id.
LoadAllByHostID(context.Context, string) ([]*Peer, error)
// LoadAllIDsByHostID returns all peer ids by host id.
LoadAllIDsByHostID(context.Context, string) ([]string, error)
// DeleteAllByHostID deletes all peers by host id.
DeleteAllByHostID(context.Context, string) error
}
PeerManager is the interface used for peer manager.
type PeerOption ¶
type PeerOption func(peer *Peer)
PeerOption is a functional option for persistent peer.
func WithConcurrentPieceCount ¶
func WithConcurrentPieceCount(count uint32) PeerOption
WithConcurrentPieceCount set ConcurrentPieceCount for peer.
type Resource ¶
type Resource interface {
// Host manager interface.
HostManager() HostManager
// Peer manager interface.
PeerManager() PeerManager
// Task manager interface.
TaskManager() TaskManager
}
Resource is the interface used for resource.
func New ¶
func New(cfg *config.Config, gc gc.GC, rdb redis.UniversalClient, transportCredentials credentials.TransportCredentials) (Resource, error)
New returns Resource interface.
type Task ¶
type Task struct {
// ID is task id.
ID string
// URL is download url.
URL string
// ObjectStorageRegion is object storage region.
ObjectStorageRegion string
// ObjectStorageEndpoint is object storage endpoint.
ObjectStorageEndpoint string
// Replica count of the persistent task. The persistent task will
// not be deleted when dfdamon runs garbage collection. It only be deleted
// when the task is deleted by the user.
PersistentReplicaCount uint64
// ContentLength is persistent task total content length.
ContentLength uint64
// TotalPieceCount is total piece count.
TotalPieceCount uint32
// Persistent task state machine.
FSM *fsm.FSM
// TTL is persistent task time to live.
TTL time.Duration
// CreatedAt is persistent task create time.
CreatedAt time.Time
// UpdatedAt is persistent task update time.
UpdatedAt time.Time
// Persistent task log.
Log *logger.SugaredLoggerOnWith
}
Task contains content for persistent task.
type TaskManager ¶
type TaskManager interface {
// Load returns persistent task by a key.
Load(context.Context, string) (*Task, bool)
// LoadCurrentReplicaCount returns current replica count of the persistent task.
LoadCurrentReplicaCount(context.Context, string) (uint64, error)
// LoadCurrentPersistentReplicaCount returns current persistent replica count of the persistent task.
LoadCurrentPersistentReplicaCount(context.Context, string) (uint64, error)
// Store sets persistent task.
Store(context.Context, *Task) error
// Delete deletes persistent task by a key.
Delete(context.Context, string) error
// LoadAll returns all persistent tasks.
LoadAll(context.Context) ([]*Task, error)
}
TaskManager is the interface used for persistent task manager.