persistentcache

package
v2.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Package persistentcache is a generated GoMock package.

Index

Constants

View Source
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"
)
View Source
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"
)
View Source
const (
	// Tiny file size is 128 bytes.
	TinyFileSize = 128

	// Empty file size is 0 bytes.
	EmptyFileSize = 0
)
View Source
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"
)
View Source
const (
	// Task is uploading.
	TaskEventUpload = "Upload"

	// Task uploaded successfully.
	TaskEventSucceeded = "Succeeded"

	// Task uploaded failed.
	TaskEventFailed = "Failed"
)
View Source
const (
	// GC persistent cache host id.
	GCHostID = "persistent-cache-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

	// DisableShared is whether the host is disabled for
	// 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

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockHostManager) Load

func (m *MockHostManager) Load(arg0 context.Context, arg1 string) (*Host, bool)

Load mocks base method.

func (*MockHostManager) LoadAll

func (m *MockHostManager) LoadAll(arg0 context.Context) ([]*Host, error)

LoadAll mocks base method.

func (*MockHostManager) LoadRandom added in v2.2.1

func (m *MockHostManager) LoadRandom(arg0 context.Context, arg1 int, arg2 set.SafeSet[string]) ([]*Host, error)

LoadRandom mocks base method.

func (*MockHostManager) RunGC added in v2.1.64

func (m *MockHostManager) RunGC(arg0 context.Context) error

RunGC mocks base method.

func (*MockHostManager) Store

func (m *MockHostManager) Store(arg0 context.Context, arg1 *Host) error

Store 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 added in v2.2.1

func (mr *MockHostManagerMockRecorder) LoadRandom(arg0, arg1, arg2 any) *gomock.Call

LoadRandom indicates an expected call of LoadRandom.

func (*MockHostManagerMockRecorder) RunGC added in v2.1.64

func (mr *MockHostManagerMockRecorder) RunGC(arg0 any) *gomock.Call

RunGC indicates an expected call of RunGC.

func (*MockHostManagerMockRecorder) Store

func (mr *MockHostManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

type MockPeerManager added in v2.1.62

type MockPeerManager struct {
	// contains filtered or unexported fields
}

MockPeerManager is a mock of PeerManager interface.

func NewMockPeerManager added in v2.1.62

func NewMockPeerManager(ctrl *gomock.Controller) *MockPeerManager

NewMockPeerManager creates a new mock instance.

func (*MockPeerManager) Delete added in v2.1.62

func (m *MockPeerManager) Delete(arg0 context.Context, arg1 string) error

Delete mocks base method.

func (*MockPeerManager) DeleteAllByHostID added in v2.1.64

func (m *MockPeerManager) DeleteAllByHostID(arg0 context.Context, arg1 string) error

DeleteAllByHostID mocks base method.

func (*MockPeerManager) DeleteAllByTaskID added in v2.1.63

func (m *MockPeerManager) DeleteAllByTaskID(arg0 context.Context, arg1 string) error

DeleteAllByTaskID mocks base method.

func (*MockPeerManager) EXPECT added in v2.1.62

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockPeerManager) Load added in v2.1.62

func (m *MockPeerManager) Load(arg0 context.Context, arg1 string) (*Peer, bool)

Load mocks base method.

func (*MockPeerManager) LoadAll added in v2.1.62

func (m *MockPeerManager) LoadAll(arg0 context.Context) ([]*Peer, error)

LoadAll mocks base method.

func (*MockPeerManager) LoadAllByHostID added in v2.1.64

func (m *MockPeerManager) LoadAllByHostID(arg0 context.Context, arg1 string) ([]*Peer, error)

LoadAllByHostID mocks base method.

func (*MockPeerManager) LoadAllByTaskID added in v2.1.63

func (m *MockPeerManager) LoadAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)

LoadAllByTaskID mocks base method.

func (*MockPeerManager) LoadAllIDsByHostID added in v2.2.1

func (m *MockPeerManager) LoadAllIDsByHostID(arg0 context.Context, arg1 string) ([]string, error)

LoadAllIDsByHostID mocks base method.

func (*MockPeerManager) LoadAllIDsByTaskID added in v2.2.1

func (m *MockPeerManager) LoadAllIDsByTaskID(arg0 context.Context, arg1 string) ([]string, error)

LoadAllIDsByTaskID mocks base method.

func (*MockPeerManager) LoadPersistentAllByTaskID added in v2.2.1

func (m *MockPeerManager) LoadPersistentAllByTaskID(arg0 context.Context, arg1 string) ([]*Peer, error)

LoadPersistentAllByTaskID mocks base method.

func (*MockPeerManager) Store added in v2.1.62

func (m *MockPeerManager) Store(arg0 context.Context, arg1 *Peer) error

Store mocks base method.

type MockPeerManagerMockRecorder added in v2.1.62

type MockPeerManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockPeerManagerMockRecorder is the mock recorder for MockPeerManager.

func (*MockPeerManagerMockRecorder) Delete added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Delete(arg0, arg1 any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockPeerManagerMockRecorder) DeleteAllByHostID added in v2.1.64

func (mr *MockPeerManagerMockRecorder) DeleteAllByHostID(arg0, arg1 any) *gomock.Call

DeleteAllByHostID indicates an expected call of DeleteAllByHostID.

func (*MockPeerManagerMockRecorder) DeleteAllByTaskID added in v2.1.63

func (mr *MockPeerManagerMockRecorder) DeleteAllByTaskID(arg0, arg1 any) *gomock.Call

DeleteAllByTaskID indicates an expected call of DeleteAllByTaskID.

func (*MockPeerManagerMockRecorder) Load added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Load(arg0, arg1 any) *gomock.Call

Load indicates an expected call of Load.

func (*MockPeerManagerMockRecorder) LoadAll added in v2.1.62

func (mr *MockPeerManagerMockRecorder) LoadAll(arg0 any) *gomock.Call

LoadAll indicates an expected call of LoadAll.

func (*MockPeerManagerMockRecorder) LoadAllByHostID added in v2.1.64

func (mr *MockPeerManagerMockRecorder) LoadAllByHostID(arg0, arg1 any) *gomock.Call

LoadAllByHostID indicates an expected call of LoadAllByHostID.

func (*MockPeerManagerMockRecorder) LoadAllByTaskID added in v2.1.63

func (mr *MockPeerManagerMockRecorder) LoadAllByTaskID(arg0, arg1 any) *gomock.Call

LoadAllByTaskID indicates an expected call of LoadAllByTaskID.

func (*MockPeerManagerMockRecorder) LoadAllIDsByHostID added in v2.2.1

func (mr *MockPeerManagerMockRecorder) LoadAllIDsByHostID(arg0, arg1 any) *gomock.Call

LoadAllIDsByHostID indicates an expected call of LoadAllIDsByHostID.

func (*MockPeerManagerMockRecorder) LoadAllIDsByTaskID added in v2.2.1

func (mr *MockPeerManagerMockRecorder) LoadAllIDsByTaskID(arg0, arg1 any) *gomock.Call

LoadAllIDsByTaskID indicates an expected call of LoadAllIDsByTaskID.

func (*MockPeerManagerMockRecorder) LoadPersistentAllByTaskID added in v2.2.1

func (mr *MockPeerManagerMockRecorder) LoadPersistentAllByTaskID(arg0, arg1 any) *gomock.Call

LoadPersistentAllByTaskID indicates an expected call of LoadPersistentAllByTaskID.

func (*MockPeerManagerMockRecorder) Store added in v2.1.62

func (mr *MockPeerManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

type MockResource added in v2.1.62

type MockResource struct {
	// contains filtered or unexported fields
}

MockResource is a mock of Resource interface.

func NewMockResource added in v2.1.62

func NewMockResource(ctrl *gomock.Controller) *MockResource

NewMockResource creates a new mock instance.

func (*MockResource) EXPECT added in v2.1.62

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResource) HostManager added in v2.1.62

func (m *MockResource) HostManager() HostManager

HostManager mocks base method.

func (*MockResource) PeerManager added in v2.1.62

func (m *MockResource) PeerManager() PeerManager

PeerManager mocks base method.

func (*MockResource) TaskManager added in v2.1.62

func (m *MockResource) TaskManager() TaskManager

TaskManager mocks base method.

type MockResourceMockRecorder added in v2.1.62

type MockResourceMockRecorder struct {
	// contains filtered or unexported fields
}

MockResourceMockRecorder is the mock recorder for MockResource.

func (*MockResourceMockRecorder) HostManager added in v2.1.62

func (mr *MockResourceMockRecorder) HostManager() *gomock.Call

HostManager indicates an expected call of HostManager.

func (*MockResourceMockRecorder) PeerManager added in v2.1.62

func (mr *MockResourceMockRecorder) PeerManager() *gomock.Call

PeerManager indicates an expected call of PeerManager.

func (*MockResourceMockRecorder) TaskManager added in v2.1.62

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

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTaskManager) Load

func (m *MockTaskManager) Load(arg0 context.Context, arg1 string) (*Task, bool)

Load mocks base method.

func (*MockTaskManager) LoadAll

func (m *MockTaskManager) LoadAll(arg0 context.Context) ([]*Task, error)

LoadAll mocks base method.

func (*MockTaskManager) LoadCurrentPersistentReplicaCount added in v2.1.64

func (m *MockTaskManager) LoadCurrentPersistentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)

LoadCurrentPersistentReplicaCount mocks base method.

func (*MockTaskManager) LoadCurrentReplicaCount added in v2.2.2

func (m *MockTaskManager) LoadCurrentReplicaCount(arg0 context.Context, arg1 string) (uint64, error)

LoadCurrentReplicaCount mocks base method.

func (*MockTaskManager) Store

func (m *MockTaskManager) Store(arg0 context.Context, arg1 *Task) error

Store 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 added in v2.1.64

func (mr *MockTaskManagerMockRecorder) LoadCurrentPersistentReplicaCount(arg0, arg1 any) *gomock.Call

LoadCurrentPersistentReplicaCount indicates an expected call of LoadCurrentPersistentReplicaCount.

func (*MockTaskManagerMockRecorder) LoadCurrentReplicaCount added in v2.2.2

func (mr *MockTaskManagerMockRecorder) LoadCurrentReplicaCount(arg0, arg1 any) *gomock.Call

LoadCurrentReplicaCount indicates an expected call of LoadCurrentReplicaCount.

func (*MockTaskManagerMockRecorder) Store

func (mr *MockTaskManagerMockRecorder) Store(arg0, arg1 any) *gomock.Call

Store indicates an expected call of Store.

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 added in v2.1.61

type Peer struct {
	// ID is persistent cache 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 cache peer state machine.
	FSM *fsm.FSM

	// Task is persistent cache 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 cache peer create time.
	CreatedAt time.Time

	// UpdatedAt is persistent cache peer update time.
	UpdatedAt time.Time

	// Persistent cache peer log.
	Log *logger.SugaredLoggerOnWith
}

Peer contains content for persistent cache peer.

func NewPeer added in v2.1.61

func NewPeer(id, state string, isPersistent bool, finishedPieces *bitset.BitSet, blockParents []string, task *Task, host *Host,
	cost time.Duration, createdAt, updatedAt time.Time, log *logger.SugaredLoggerOnWith, options ...PeerOption) *Peer

New persistent cache peer instance.

type PeerManager added in v2.1.62

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 added in v2.3.4

type PeerOption func(peer *Peer)

PeerOption is a functional option for persistent cache peer.

func WithConcurrentPieceCount added in v2.3.4

func WithConcurrentPieceCount(count uint32) PeerOption

WithConcurrentPieceCount set ConcurrentPieceCount for peer.

type Resource added in v2.1.62

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 added in v2.1.62

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

	// Replica count of the persistent cache task. The persistent cache task will
	// not be deleted when dfdamon runs garbage collection. It only be deleted
	// when the task is deleted by the user.
	PersistentReplicaCount uint64

	// Tag is used to distinguish different persistent cache tasks.
	Tag string

	// Application of persistent cache task.
	Application string

	// Persistet cache task piece length.
	PieceLength uint64

	// ContentLength is persistent cache task total content length.
	ContentLength uint64

	// TotalPieceCount is total piece count.
	TotalPieceCount uint32

	// Persistent cache task state machine.
	FSM *fsm.FSM

	// TTL is persistent cache task time to live.
	TTL time.Duration

	// CreatedAt is persistent cache task create time.
	CreatedAt time.Time

	// UpdatedAt is persistent cache task update time.
	UpdatedAt time.Time

	// Persistent cache task log.
	Log *logger.SugaredLoggerOnWith
}

Task contains content for persistent cache task.

func NewTask

func NewTask(id, tag, application, state string, persistentReplicaCount, pieceLength, contentLength uint64,
	totalPieceCount uint32, ttl time.Duration, createdAt, updatedAt time.Time,
	log *logger.SugaredLoggerOnWith) *Task

New persistent cache task instance.

func (*Task) SizeScope added in v2.2.1

func (t *Task) SizeScope() commonv2.SizeScope

SizeScope return task size scope type.

type TaskManager

type TaskManager interface {
	// Load returns persistent cache task by a key.
	Load(context.Context, string) (*Task, bool)

	// LoadCurrentReplicaCount returns current replica count of the persistent cache task.
	LoadCurrentReplicaCount(context.Context, string) (uint64, error)

	// LoadCurrentPersistentReplicaCount returns current persistent replica count of the persistent cache task.
	LoadCurrentPersistentReplicaCount(context.Context, string) (uint64, error)

	// Store sets persistent cache task.
	Store(context.Context, *Task) error

	// Delete deletes persistent cache task by a key.
	Delete(context.Context, string) error

	// LoadAll returns all persistent cache tasks.
	LoadAll(context.Context) ([]*Task, error)
}

TaskManager is the interface used for persistent cache task manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL