types

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const (
	TCP = Protocol("TCP")
	UDP = Protocol("UDP")
)
View Source
const (
	ShellCodeStdout         = 100
	ShellCodeStderr         = 101
	ShellCodeResult         = 102
	ShellCodeFailure        = 103
	ShellCodeStdin          = 104
	ShellCodeTerminalResize = 105
	ShellCodeEOF            = 106
)

Variables

View Source
var FuncAccessControlMap = map[string]UserAccessControl{
	"CreateAsset":      UserAPIKeyCreateFile,
	"ListAssets":       UserAPIKeyReadFile,
	"DeleteAsset":      UserAPIKeyDeleteFile,
	"ShareAssets":      UserAPIKeyReadFile,
	"CreateAssetGroup": UserAPIKeyCreateFolder,
	"ListAssetGroup":   UserAPIKeyReadFolder,
	"DeleteAssetGroup": UserAPIKeyDeleteFolder,
	"RenameAssetGroup": UserAPIKeyCreateFolder,
}

key is function name, value is permission name

ReplicaStatusAll contains all possible replica statuses

Functions

func DeploymentStateString added in v0.1.21

func DeploymentStateString(state DeploymentState) string

func ProviderStateString added in v0.1.21

func ProviderStateString(state ProviderState) string

Types

type AWSDataInfo added in v0.1.13

type AWSDataInfo struct {
	Bucket         string    `db:"bucket"`
	Cid            string    `db:"cid"`
	Replicas       int       `db:"replicas"`
	IsDistribute   bool      `db:"is_distribute"`
	DistributeTime time.Time `db:"distribute_time"`
	Size           float64   `db:"size"`
}

AWSDataInfo aws data

type AWSDownloadSources added in v0.1.19

type AWSDownloadSources struct {
	Bucket string
	Key    string
}

type AccessPointRsp added in v0.1.21

type AccessPointRsp struct {
	Schedulers []string
	GeoInfo    *region.GeoInfo
}

type ActivationDetail added in v0.1.10

type ActivationDetail struct {
	NodeID        string   `json:"node_id" db:"node_id"`
	AreaID        string   `json:"area_id" `
	ActivationKey string   `json:"activation_key" db:"activation_key"`
	NodeType      NodeType `json:"node_type" db:"node_type"`
	IP            string   `json:"ip" db:"ip"`
}

func (*ActivationDetail) Marshal added in v0.1.10

func (d *ActivationDetail) Marshal() (string, error)

func (*ActivationDetail) Unmarshal added in v0.1.10

func (d *ActivationDetail) Unmarshal(code string) error

type AppType added in v0.1.21

type AppType int
const (
	AppTypeL1 AppType = iota + 1
)

type Arguments added in v0.1.21

type Arguments []string

func (Arguments) Scan added in v0.1.21

func (a Arguments) Scan(value interface{}) error

func (Arguments) Value added in v0.1.21

func (a Arguments) Value() (driver.Value, error)

type AssetGroup added in v0.1.11

type AssetGroup struct {
	ID          int       `db:"id"`
	UserID      string    `db:"user_id"`
	Name        string    `db:"name"`
	Parent      int       `db:"parent"`
	AssetCount  int       `db:"asset_count"`
	AssetSize   int64     `db:"asset_size"`
	CreatedTime time.Time `db:"created_time"`
}

AssetGroup user asset group

type AssetHash

type AssetHash string

AssetHash is an identifier for a asset.

func (AssetHash) String

func (c AssetHash) String() string

type AssetOverview added in v0.1.11

type AssetOverview struct {
	AssetRecord      *AssetRecord
	UserAssetDetail  *UserAssetDetail
	VisitCount       int
	RemainVisitCount int
}

type AssetPullProgress

type AssetPullProgress struct {
	CID             string
	Status          ReplicaStatus
	Msg             string
	BlocksCount     int
	DoneBlocksCount int
	Size            int64
	DoneSize        int64
}

AssetPullProgress represents the progress of pulling an asset

type AssetPullRequest added in v0.1.19

type AssetPullRequest struct {
	AssetCID   string
	Dss        *DownloadSources
	WorkloadID string
}

type AssetRecord

type AssetRecord struct {
	CID                   string          `db:"cid"`
	Hash                  string          `db:"hash"`
	NeedEdgeReplica       int64           `db:"edge_replicas"`
	TotalSize             int64           `db:"total_size"`
	TotalBlocks           int64           `db:"total_blocks"`
	Expiration            time.Time       `db:"expiration"`
	CreatedTime           time.Time       `db:"created_time"`
	EndTime               time.Time       `db:"end_time"`
	NeedCandidateReplicas int64           `db:"candidate_replicas"`
	ServerID              dtypes.ServerID `db:"scheduler_sid"`
	State                 string          `db:"state"`
	NeedBandwidth         int64           `db:"bandwidth"` // unit:MiB/
	Note                  string          `db:"note"`
	Source                int64           `db:"source"`

	RetryCount        int64 `db:"retry_count"`
	ReplenishReplicas int64 `db:"replenish_replicas"`
	ReplicaInfos      []*ReplicaInfo

	SPCount int64
}

AssetRecord represents information about an asset record

type AssetSource added in v0.1.18

type AssetSource int64

AssetSource aws or storage

const (
	// AssetSourceAdminPull
	AssetSourceAdminPull AssetSource = iota
	// AssetSourceAWS status
	AssetSourceAWS
	// AssetSourceStorage status
	AssetSourceStorage
	// AssetSourceMinio status
	AssetSourceMinio
)

type AssetSourceDownloadInfoRsp added in v0.1.18

type AssetSourceDownloadInfoRsp struct {
	WorkloadID string

	// download from aws
	AWSBucket string
	// download from aws
	AWSKey string

	SchedulerURL string

	SourceList []*SourceDownloadInfo
}

type AssetStateInfo

type AssetStateInfo struct {
	State             string `db:"state"`
	RetryCount        int64  `db:"retry_count"`
	Hash              string `db:"hash"`
	ReplenishReplicas int64  `db:"replenish_replicas"`
}

AssetStateInfo represents information about an asset state

type AssetStatistics

type AssetStatistics struct {
	ReplicaCount      int
	UserDownloadCount int
}

AssetStatistics Statistics on asset pulls and downloads

type AssetStats

type AssetStats struct {
	TotalAssetCount     int
	TotalBlockCount     int
	WaitCacheAssetCount int
	InProgressAssetCID  string
	DiskUsage           float64
}

AssetStats contains statistics about assets

type AssetStatus added in v0.1.11

type AssetStatus struct {
	IsExist           bool
	IsExpiration      bool
	IsVisitOutOfLimit bool
}

type AssetType added in v0.1.10

type AssetType int

AssetType represents the type of a asset

const (
	// AssetTypeCarfile type
	AssetTypeCarfile AssetType = iota
	// AssetTypeFile type
	AssetTypeFile
)

type AssetView added in v0.1.14

type AssetView struct {
	TopHash string
	// key bucketID, value bucketHash
	BucketHashes map[uint32]string
}

type AuthUserDeployment added in v0.1.21

type AuthUserDeployment struct {
	UserID       string
	DeploymentID string
	Expiration   time.Time
}

type AuthUserUploadDownloadAsset added in v0.1.11

type AuthUserUploadDownloadAsset struct {
	UserID     string
	AssetCID   string
	AssetSize  int64
	Expiration time.Time
}

type CPUCores added in v0.1.21

type CPUCores struct {
	MaxCPUCores float64
	Available   float64
	Active      float64
	Pending     float64
}

type CandidateCodeInfo added in v0.1.19

type CandidateCodeInfo struct {
	Code       string    `db:"code"`
	NodeType   NodeType  `db:"node_type"`
	Expiration time.Time `db:"expiration"`
	NodeID     string    `db:"node_id"`
	IsTest     bool      `db:"is_test"`
}

type CandidateDownloadInfo

type CandidateDownloadInfo struct {
	NodeID  string
	Address string
	Tk      *Token
	// download from aws
	AWSBucket string
	// download from aws
	AWSKey string
}

CandidateDownloadInfo represents download information for a candidate

type Certificate added in v0.1.21

type Certificate struct {
	Hostname    string
	PrivateKey  []byte
	Certificate []byte
}

type ComputeResources added in v0.1.21

type ComputeResources struct {
	CPU     float64  `db:"cpu"`
	GPU     float64  `db:"gpu"`
	Memory  int64    `db:"memory"`
	Storage Storages `db:"storage"`
}

type ConnectOptions

type ConnectOptions struct {
	Token         string
	TcpServerPort int
	// private minio storage only, not public storage
	IsPrivateMinioOnly bool
	ExternalURL        string

	GeoInfo *region.GeoInfo
}

type CreateAssetReq added in v0.1.10

type CreateAssetReq struct {
	UserID        string
	AssetCID      string
	AssetSize     int64
	NodeID        string
	ReplicaCount  int64
	ExpirationDay int
}

type CreateSyncAssetReq added in v0.1.21

type CreateSyncAssetReq struct {
	AssetCID      string
	AssetSize     int64
	ReplicaCount  int64
	ExpirationDay int

	DownloadInfo *SourceDownloadInfo
}

type CreateTunnelReq added in v0.1.21

type CreateTunnelReq struct {
	NodeID    string
	ProjectID string
	WsURL     string
	TunnelID  string
}

type DeployProjectReq added in v0.1.19

type DeployProjectReq struct {
	UUID       string
	Name       string
	BundleURL  string
	UserID     string
	Replicas   int64
	Expiration time.Time

	CPUCores int64
	Memory   float64
	AreaID   string
	NodeIDs  []string
}

type Deployment added in v0.1.21

type Deployment struct {
	ID        DeploymentID    `db:"id"`
	Name      string          `db:"name"`
	Owner     string          `db:"owner"`
	State     DeploymentState `db:"state"`
	Version   string          `db:"version"`
	Authority bool            `db:"authority"`
	Services  []*Service

	// Internal
	Type             DeploymentType `db:"type"`
	Balance          float64        `db:"balance"`
	Cost             float64        `db:"cost"`
	ProviderID       string         `db:"provider_id"`
	Expiration       time.Time      `db:"expiration"`
	CreatedAt        time.Time      `db:"created_at"`
	UpdatedAt        time.Time      `db:"updated_at"`
	ProviderExposeIP string         `db:"provider_expose_ip"`
}

type DeploymentDomain added in v0.1.21

type DeploymentDomain struct {
	ID           int       `db:"id"`
	Name         string    `db:"name"`
	State        string    `db:"state"`
	DeploymentID string    `db:"deployment_id"`
	ProviderID   string    `db:"provider_id"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

type DeploymentID added in v0.1.21

type DeploymentID string

type DeploymentState added in v0.1.21

type DeploymentState int
const (
	DeploymentStateActive DeploymentState = iota + 1
	DeploymentStateInActive
	DeploymentStateClose
)

type DeploymentType added in v0.1.21

type DeploymentType int
const (
	DeploymentTypeWeb DeploymentType = iota + 1
)

type DownloadHistory

type DownloadHistory struct {
	ID           string    `json:"-"`
	NodeID       string    `json:"node_id" db:"node_id"`
	BlockCID     string    `json:"block_cid" db:"block_cid"`
	AssetCID     string    `json:"asset_cid" db:"asset_cid"`
	BlockSize    int       `json:"block_size" db:"block_size"`
	Speed        int64     `json:"speed" db:"speed"`
	Reward       int64     `json:"reward" db:"reward"`
	Status       int       `json:"status" db:"status"`
	FailedReason string    `json:"failed_reason" db:"failed_reason"`
	ClientIP     string    `json:"client_ip" db:"client_ip"`
	CreatedTime  time.Time `json:"created_time" db:"created_time"`
	CompleteTime time.Time `json:"complete_time" db:"complete_time"`
}

DownloadHistory represents the record of a node download

type DownloadSources added in v0.1.19

type DownloadSources struct {
	Nodes []*SourceDownloadInfo
	AWS   *AWSDownloadSources
}

type EdgeDownloadInfo

type EdgeDownloadInfo struct {
	Address string
	Tk      *Token
	NodeID  string
	NatType string
}

EdgeDownloadInfo represents download information for an edge node

type EdgeDownloadInfoList

type EdgeDownloadInfoList struct {
	Infos        []*EdgeDownloadInfo
	SchedulerURL string
	SchedulerKey string
}

EdgeDownloadInfoList represents a list of EdgeDownloadInfo structures along with scheduler URL and key

type Env added in v0.1.21

type Env map[string]string

func (Env) Scan added in v0.1.21

func (e Env) Scan(value interface{}) error

func (Env) Value added in v0.1.21

func (e Env) Value() (driver.Value, error)

type Event added in v0.1.21

type Event string

type EventTopics

type EventTopics string

EventTopics represents topics for pub/sub events

const (
	// EventNodeOnline node online event
	EventNodeOnline EventTopics = "node_online"
	// EventNodeOffline node offline event
	EventNodeOffline EventTopics = "node_offline"
)

func (EventTopics) String

func (t EventTopics) String() string

type ExecResult added in v0.1.21

type ExecResult struct {
	Code int
}

type ExitProfitRsp added in v0.1.19

type ExitProfitRsp struct {
	CurrentPoint   float64
	RemainingPoint float64
	PenaltyRate    float64
}

type FreeUpDiskResp added in v0.1.19

type FreeUpDiskResp struct {
	Hashes   []string
	NextTime int64
}

type FreeUpDiskState added in v0.1.19

type FreeUpDiskState struct {
	Hash   string
	ErrMsg string
}

type FreeUpDiskStateResp added in v0.1.19

type FreeUpDiskStateResp struct {
	Hashes   []*FreeUpDiskState
	NextTime int64
}

type GeneratedCarInfo added in v0.1.10

type GeneratedCarInfo struct {
	DataCid   string
	PieceCid  string
	PieceSize uint64
	Path      string
}

type GetDeploymentListResp added in v0.1.21

type GetDeploymentListResp struct {
	Deployments []*Deployment
	Total       int64
}

type GetDeploymentOption added in v0.1.21

type GetDeploymentOption struct {
	Owner        string
	DeploymentID DeploymentID
	ProviderID   string
	State        []DeploymentState
	Page         int
	Size         int
}

type GetProviderOption added in v0.1.21

type GetProviderOption struct {
	Owner string
	ID    string
	State []ProviderState
	Page  int
	Size  int
}

type InProgressAsset

type InProgressAsset struct {
	CID       string
	TotalSize int64
	DoneSize  int64
}

InProgressAsset represents an asset that is currently being fetched, including its progress details.

type Ingress added in v0.1.21

type Ingress struct {
	Annotations map[string]string
}

type JWTPayload added in v0.1.10

type JWTPayload struct {
	// role base access controller permission
	Allow []auth.Permission
	ID    string
	// TODO remove NodeID later, any role id replace as ID
	NodeID string
	// Extend is json string
	Extend string
	// The sub permission of user
	AccessControlList []UserAccessControl
}

type LeaseEndpoint added in v0.1.21

type LeaseEndpoint struct {
	Scheme    string
	Host      string
	ShellPath string
	Token     string
}

type ListAssetGroupRsp added in v0.1.11

type ListAssetGroupRsp struct {
	Total       int           `json:"total"`
	AssetGroups []*AssetGroup `json:"infos"`
}

ListAssetGroupRsp list asset group records

type ListAssetRecordRsp added in v0.1.11

type ListAssetRecordRsp struct {
	Total          int              `json:"total"`
	AssetOverviews []*AssetOverview `json:"asset_infos"`
}

ListAssetRecordRsp list asset records

type ListAssetSummaryRsp added in v0.1.11

type ListAssetSummaryRsp struct {
	Total int                 `json:"total"`
	List  []*UserAssetSummary `json:"list"`
}

ListAssetSummaryRsp list asset and group

type ListDownloadRecordRsp

type ListDownloadRecordRsp struct {
	Data  []DownloadHistory `json:"data"`
	Total int64             `json:"total"`
}

ListDownloadRecordRsp download record rsp

type ListNodeAssetRsp added in v0.1.10

type ListNodeAssetRsp struct {
	Total          int              `json:"total"`
	NodeAssetInfos []*NodeAssetInfo `json:"asset_infos"`
}

ListNodeAssetRsp list node assets

type ListNodeProfitDetailsRsp added in v0.1.18

type ListNodeProfitDetailsRsp struct {
	Total int              `json:"total"`
	Infos []*ProfitDetails `json:"infos"`
}

ListNodeProfitDetailsRsp list node profit

type ListNodeReplicaRsp added in v0.1.16

type ListNodeReplicaRsp struct {
	Total            int                `json:"total"`
	NodeReplicaInfos []*NodeReplicaInfo `json:"infos"`
}

ListNodeReplicaRsp list node assets

type ListNodesRsp

type ListNodesRsp struct {
	Data  []NodeInfo `json:"data"`
	Total int64      `json:"total"`
}

ListNodesRsp list node rsp

type ListReplicaEventRsp added in v0.1.10

type ListReplicaEventRsp struct {
	Total         int                 `json:"total"`
	ReplicaEvents []*ReplicaEventInfo `json:"replica_events"`
}

ListReplicaEventRsp list replica events

type ListReplicaRsp added in v0.1.11

type ListReplicaRsp struct {
	Total        int            `json:"total"`
	ReplicaInfos []*ReplicaInfo `json:"replica_infos"`
}

ListReplicaRsp list asset replicas

type ListRetrieveEventRsp added in v0.1.11

type ListRetrieveEventRsp struct {
	Total              int              `json:"total"`
	RetrieveEventInfos []*RetrieveEvent `json:"retrieve_event_infos"`
}

ListRetrieveEventRsp list retrieve event

type ListStorageStatsRsp added in v0.1.11

type ListStorageStatsRsp struct {
	Total    int             `json:"total"`
	Storages []*StorageStats `json:"infos"`
}

ListStorageStatsRsp list storage stats records

type ListValidationResultRsp

type ListValidationResultRsp struct {
	Total                 int                    `json:"total"`
	ValidationResultInfos []ValidationResultInfo `json:"validation_result_infos"`
}

ListValidationResultRsp list validated result

type ListWorkloadRecordRsp added in v0.1.10

type ListWorkloadRecordRsp struct {
	Total               int               `json:"total"`
	WorkloadRecordInfos []*WorkloadRecord `json:"workload_result_infos"`
}

ListWorkloadRecordRsp list workload result

type Log added in v0.1.21

type Log string

type Memory added in v0.1.21

type Memory struct {
	MaxMemory uint64
	Available uint64
	Active    uint64
	Pending   uint64
}

type MinioConfig added in v0.1.11

type MinioConfig struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
}

type MinioUploadFileEvent added in v0.1.11

type MinioUploadFileEvent struct {
	AssetCID   string
	Size       int64
	CreateTime time.Time
	Expiration time.Time
}

type NatPunchReq

type NatPunchReq struct {
	Tk      *Token
	NodeID  string
	Timeout time.Duration
}

type NatType

type NatType int

NatType represents the type of NAT of a node

const (
	// NatTypeUnknown Unknown NAT type
	NatTypeUnknown NatType = iota
	// NatTypeNo not  nat
	NatTypeNo
	// NatTypeSymmetric Symmetric NAT
	NatTypeSymmetric // NAT4
	// NatTypeFullCone Full cone NAT
	NatTypeFullCone // NAT1
	// NatTypeRestricted Restricted NAT
	NatTypeRestricted // NAT2
	// NatTypePortRestricted Port-restricted NAT
	NatTypePortRestricted // NAT3
)

func (NatType) FromString

func (n NatType) FromString(natType string) NatType

func (NatType) String

func (n NatType) String() string

type NodeActivation added in v0.1.10

type NodeActivation struct {
	NodeID         string
	ActivationCode string
}

type NodeAssetInfo added in v0.1.10

type NodeAssetInfo struct {
	Hash       string    `db:"hash"`
	Cid        string    `db:"cid"`
	TotalSize  int64     `db:"total_size"`
	Expiration time.Time `db:"expiration"`
	EndTime    time.Time `db:"end_time"`
}

NodeAssetInfo node asset info of web

type NodeClientType added in v0.1.19

type NodeClientType int

NodeClientType node client type

const (
	NodeOther NodeClientType = iota
	NodeWindows
	NodeMacos
	NodeAndroid
	NodeIOS
)

type NodeDynamicInfo added in v0.1.10

type NodeDynamicInfo struct {
	NodeID             string    `json:"node_id" form:"nodeId" gorm:"column:node_id;comment:;" db:"node_id"`
	OnlineDuration     int       `db:"online_duration"`  // unit:Minute
	OfflineDuration    int       `db:"offline_duration"` // unit:Minute
	DiskUsage          float64   `json:"disk_usage" form:"diskUsage" gorm:"column:disk_usage;comment:;" db:"disk_usage"`
	LastSeen           time.Time `db:"last_seen"`
	Profit             float64   `db:"profit"`
	PenaltyProfit      float64   `db:"penalty_profit"`
	TitanDiskUsage     float64   `db:"titan_disk_usage"`
	AvailableDiskSpace float64   `json:"available_disk_space" form:"availableDiskSpace" gorm:"column:available_disk_space;comment:;" db:"available_disk_space"`
	BandwidthUp        int64     `json:"bandwidth_up" db:"bandwidth_up"`
	BandwidthDown      int64     `json:"bandwidth_down" db:"bandwidth_down"`
	DownloadTraffic    int64     `db:"download_traffic"`
	UploadTraffic      int64     `db:"upload_traffic"`
}

NodeDynamicInfo contains the real-time status information of a node, such as the last online time, online duration, CPU usage rate, and score changes.

type NodeIPInfo added in v0.1.11

type NodeIPInfo struct {
	NodeID      string
	IP          string
	ExternalURL string
}

NodeIPInfo

type NodeInfo

type NodeInfo struct {
	IsTestNode      bool
	Type            NodeType
	ExternalIP      string
	InternalIP      string
	CPUUsage        float64
	MemoryUsage     float64
	Status          NodeStatus
	NATType         string
	ClientType      NodeClientType
	BackProjectTime int64
	RemoteAddr      string
	Level           int
	IncomeIncr      float64 // Base points increase every half hour (30 minute)
	AreaID          string
	Mx              float64
	AssetCount      int64 `db:"asset_count"`
	RetrieveCount   int64 `db:"retrieve_count"`

	FirstTime      time.Time       `db:"first_login_time"`
	NetFlowUp      int64           `json:"netflow_up" db:"netflow_up" gorm:"column:netflow_up;"`
	NetFlowDown    int64           `json:"netflow_down" db:"netflow_down" gorm:"column:netflow_down;"`
	DiskSpace      float64         `json:"disk_space" form:"diskSpace" gorm:"column:disk_space;comment:;" db:"disk_space"`
	SystemVersion  string          `json:"system_version" form:"systemVersion" gorm:"column:system_version;comment:;" db:"system_version"`
	DiskType       string          `json:"disk_type" form:"diskType" gorm:"column:disk_type;comment:;" db:"disk_type"`
	IoSystem       string          `json:"io_system" form:"ioSystem" gorm:"column:io_system;comment:;" db:"io_system"`
	NodeName       string          `json:"node_name" form:"nodeName" gorm:"column:node_name;comment:;" db:"node_name"`
	Memory         float64         `json:"memory" form:"memory" gorm:"column:memory;comment:;" db:"memory"`
	CPUCores       int             `json:"cpu_cores" form:"cpuCores" gorm:"column:cpu_cores;comment:;" db:"cpu_cores"`
	MacLocation    string          `json:"mac_location" form:"macLocation" gorm:"column:mac_location;comment:;" db:"mac_location"`
	PortMapping    string          `db:"port_mapping"`
	SchedulerID    dtypes.ServerID `db:"scheduler_sid"`
	DeactivateTime int64           `db:"deactivate_time"`
	CPUInfo        string          `json:"cpu_info" form:"cpuInfo" gorm:"column:cpu_info;comment:;" db:"cpu_info"`
	GPUInfo        string          `json:"gpu_info" form:"gpuInfo" gorm:"column:gpu_info;comment:;" db:"gpu_info"`
	FreeUpFiskTime time.Time       `db:"free_up_disk_time"`
	WSServerID     string          `db:"ws_server_id"`

	NodeDynamicInfo
}

NodeInfo contains information about a node.

type NodeReplicaInfo added in v0.1.16

type NodeReplicaInfo struct {
	Hash      string        `db:"hash"`
	Cid       string        `db:"cid"`
	TotalSize int64         `db:"total_size"`
	Status    ReplicaStatus `db:"status"`
	DoneSize  int64         `db:"done_size"`
	StartTime time.Time     `db:"start_time"`
	EndTime   time.Time     `db:"end_time"`
}

NodeReplicaInfo node replica info of web

type NodeReplicaRsp

type NodeReplicaRsp struct {
	Replica    []*NodeReplicaStatus
	TotalCount int
}

NodeReplicaRsp represents the replicas of a node asset

type NodeReplicaStatus

type NodeReplicaStatus struct {
	Hash   string        `db:"hash"`
	Status ReplicaStatus `db:"status"`
}

NodeReplicaStatus represents the status of a node cache

type NodeStatus added in v0.1.10

type NodeStatus int

NodeStatus node status

const (
	NodeOffline NodeStatus = iota

	NodeServicing
)

func (NodeStatus) String added in v0.1.10

func (n NodeStatus) String() string

type NodeType

type NodeType int

NodeType node type

const (
	NodeUnknown NodeType = iota

	NodeEdge
	NodeCandidate
	NodeValidator
	NodeScheduler
	NodeLocator
	NodeUpdater
	NodeL5
)
var RunningNodeType NodeType

RunningNodeType represents the type of the running node.

func (NodeType) String

func (n NodeType) String() string

type NodeUploadInfo added in v0.1.21

type NodeUploadInfo struct {
	UploadURL string
	Token     string
	NodeID    string
}

type NodeWorkloadReport

type NodeWorkloadReport struct {
	// CipherText encrypted []*WorkloadReport by scheduler public key
	CipherText []byte
	// Sign signs CipherText by node private key
	Sign []byte
}

type OSType added in v0.1.21

type OSType string
const (
	OSTypeWindows OSType = "windows"
	OSTypeLinux   OSType = "linux"
)

type OpenRPCDocument

type OpenRPCDocument map[string]interface{}

type Port added in v0.1.21

type Port struct {
	Protocol   Protocol `db:"protocol"`
	Port       int      `db:"port"`
	ExposePort int      `db:"expose_port"`
}

type Ports added in v0.1.21

type Ports []Port

func (Ports) Scan added in v0.1.21

func (a Ports) Scan(value interface{}) error

func (Ports) Value added in v0.1.21

func (a Ports) Value() (driver.Value, error)

type ProfitDetails added in v0.1.18

type ProfitDetails struct {
	ID          int64      `db:"id"`
	NodeID      string     `db:"node_id"`
	Profit      float64    `db:"profit"`
	CreatedTime time.Time  `db:"created_time"`
	PType       ProfitType `db:"profit_type"`
	Size        int64      `db:"size"`
	Note        string     `db:"note"`
	CID         string     `db:"cid"`
	Rate        float64    `db:"rate"`
	Penalty     float64
}

type ProfitType added in v0.1.18

type ProfitType int

ProfitType represents the type of profit

const (
	// ProfitTypeBase
	ProfitTypeBase ProfitType = iota
	// ProfitTypePull
	ProfitTypePull
	// ProfitTypeBePull
	ProfitTypeBePull
	// ProfitTypeValidatable
	ProfitTypeValidatable
	// ProfitTypeValidator
	ProfitTypeValidator
	// ProfitTypeDownload
	ProfitTypeDownload
	// ProfitTypeUpload
	ProfitTypeUpload
	// ProfitTypeOfflinePenalty
	ProfitTypeOfflinePenalty
	// ProfitTypeReimburse
	ProfitTypeReimburse
)

type Project added in v0.1.19

type Project struct {
	ID        string // Id
	Name      string
	Status    ProjectReplicaStatus
	BundleURL string
	Port      int

	Msg string
}

type ProjectEvent added in v0.1.19

type ProjectEvent int
const (
	ProjectEventRemove ProjectEvent = iota
	ProjectEventAdd
	ProjectEventNodeOffline

	ProjectEventStatusChange
	ProjectEventExpiration
)

type ProjectInfo added in v0.1.19

type ProjectInfo struct {
	// uuid
	UUID        string          `db:"id"`
	State       string          `db:"state"`
	Name        string          `db:"name"`
	BundleURL   string          `db:"bundle_url"`
	Replicas    int64           `db:"replicas"`
	ServerID    dtypes.ServerID `db:"scheduler_sid"`
	Expiration  time.Time       `db:"expiration"`
	CreatedTime time.Time       `db:"created_time"`
	UserID      string          `db:"user_id"`

	CPUCores int64   `db:"cpu_cores"`
	Memory   float64 `db:"memory"`
	AreaID   string  `db:"area_id"`

	DetailsList       []*ProjectReplicas
	RetryCount        int64 `db:"retry_count"`
	ReplenishReplicas int64 `db:"replenish_replicas"`
}

type ProjectRecordReq added in v0.1.21

type ProjectRecordReq struct {
	NodeID            string
	ProjectID         string
	BandwidthUpSize   float64
	BandwidthDownSize float64
	StartTime         time.Time
	EndTime           time.Time
}

ProjectRecordReq

type ProjectReplicaStatus added in v0.1.19

type ProjectReplicaStatus int
const (
	ProjectReplicaStatusStarting ProjectReplicaStatus = iota
	ProjectReplicaStatusStarted
	ProjectReplicaStatusError
	ProjectReplicaStatusOffline
)

func (ProjectReplicaStatus) String added in v0.1.19

func (ps ProjectReplicaStatus) String() string

String status to string

type ProjectReplicas added in v0.1.19

type ProjectReplicas struct {
	Id          string               `db:"id"`
	Status      ProjectReplicaStatus `db:"status"`
	NodeID      string               `db:"node_id"`
	CreatedTime time.Time            `db:"created_time"`
	EndTime     time.Time            `db:"end_time"`

	WsURL     string
	BundleURL string
	IP        string
	GeoID     string
}

type ProjectReq added in v0.1.19

type ProjectReq struct {
	UUID   string
	NodeID string
	UserID string

	Name      string
	BundleURL string
	Replicas  int64
}

type ProjectStateInfo added in v0.1.19

type ProjectStateInfo struct {
	ID                string `db:"id"`
	State             string `db:"state"`
	RetryCount        int64  `db:"retry_count"`
	ReplenishReplicas int64  `db:"replenish_replicas"`
}

ProjectStateInfo represents information about an project state

type Properties added in v0.1.21

type Properties struct {
	ProviderID string  `db:"provider_id"`
	AppID      string  `db:"app_id"`
	AppType    AppType `db:"app_type"`

	// internal
	ID        int       `db:"id"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type Protocol added in v0.1.21

type Protocol string

type Provider added in v0.1.21

type Provider struct {
	ID         string        `db:"id"`
	Owner      string        `db:"owner"`
	RemoteAddr string        `db:"remote_addr"`
	IP         string        `db:"ip"`
	State      ProviderState `db:"state"`
	Scheme     string        `db:"-"`
	CreatedAt  time.Time     `db:"created_at"`
	UpdatedAt  time.Time     `db:"updated_at"`
}

type ProviderState added in v0.1.21

type ProviderState int
const (
	ProviderStateOnline ProviderState = iota + 1
	ProviderStateOffline
	ProviderStateAbnormal
)

type PullAssetReq

type PullAssetReq struct {
	CID        string
	Replicas   int64
	Expiration time.Time

	Bucket    string
	Hash      string
	Bandwidth int64 // unit:MiB/s

	SeedNodeID        string
	CandidateReplicas int64

	CandidateNodeList []string
	EdgeNodeList      []string
}

PullAssetReq represents a request to pull an asset to Titan

type PullResult

type PullResult struct {
	Progresses       []*AssetPullProgress
	DiskUsage        float64
	TotalBlocksCount int
	AssetCount       int
}

PullResult contains information about the result of a data pull

type RateLimiter added in v0.1.18

type RateLimiter struct {
	BandwidthUpLimiter   *rate.Limiter
	BandwidthDownLimiter *rate.Limiter
}

type RemoveAssetResult

type RemoveAssetResult struct {
	BlocksCount int
	DiskUsage   float64
}

RemoveAssetResult contains information about the result of removing an asset

type ReplicaEvent added in v0.1.10

type ReplicaEvent int
const (
	// ReplicaEventRemove event
	ReplicaEventRemove ReplicaEvent = iota
	// ReplicaEventAdd event
	ReplicaEventAdd
	// MinioEventAdd event
	MinioEventAdd
)

type ReplicaEventInfo added in v0.1.10

type ReplicaEventInfo struct {
	NodeID  string       `db:"node_id"`
	Event   ReplicaEvent `db:"event"`
	Hash    string       `db:"hash"`
	EndTime time.Time    `db:"end_time"`
	Source  int64        `db:"source"`

	Cid        string    `db:"cid"`
	TotalSize  int64     `db:"total_size"`
	Expiration time.Time `db:"expiration"`
}

ReplicaEventInfo replica event info

type ReplicaInfo

type ReplicaInfo struct {
	Hash        string        `db:"hash"`
	NodeID      string        `db:"node_id"`
	Status      ReplicaStatus `db:"status"`
	IsCandidate bool          `db:"is_candidate"`
	EndTime     time.Time     `db:"end_time"`
	DoneSize    int64         `db:"done_size"`
	StartTime   time.Time     `db:"start_time"`
}

ReplicaInfo represents information about an asset replica

type ReplicaStatus

type ReplicaStatus int

ReplicaStatus represents the status of a replica pull

const (
	// ReplicaStatusWaiting status
	ReplicaStatusWaiting ReplicaStatus = iota
	// ReplicaStatusPulling status
	ReplicaStatusPulling
	// ReplicaStatusFailed status
	ReplicaStatusFailed
	// ReplicaStatusSucceeded status
	ReplicaStatusSucceeded
)

func (ReplicaStatus) String

func (c ReplicaStatus) String() string

String status to string

type ReplicasStatus added in v0.1.21

type ReplicasStatus struct {
	TotalReplicas     int
	ReadyReplicas     int
	AvailableReplicas int
}

type ResourcesStatistics added in v0.1.21

type ResourcesStatistics struct {
	Memory   Memory
	CPUCores CPUCores
	Storage  StorageStat
}

type RetrieveEvent added in v0.1.11

type RetrieveEvent struct {
	TokenID     string  `db:"token_id"`
	NodeID      string  `db:"node_id"`
	ClientID    string  `db:"client_id"`
	CID         string  `db:"cid"`
	Size        int64   `db:"size"`
	CreatedTime int64   `db:"created_time"`
	EndTime     int64   `db:"end_time"`
	Profit      float64 `db:"profit"`
}

RetrieveEvent retrieve event

type SchedulerCfg

type SchedulerCfg struct {
	SchedulerURL string `db:"scheduler_url"`
	AreaID       string `db:"area_id"`
	Weight       int    `db:"weight"`
	AccessToken  string `db:"access_token"`
}

SchedulerCfg scheduler config

type Service added in v0.1.21

type Service struct {
	Image        string         `db:"image"`
	Name         string         `db:"name"`
	Ports        Ports          `db:"ports"`
	Env          Env            `db:"env"`
	Status       ReplicasStatus `db:"status"`
	ErrorMessage string         `db:"error_message"`
	Arguments    Arguments      `db:"arguments"`
	ComputeResources
	OSType   OSType `db:"os_type"`
	Replicas int32  `db:"replicas"`

	// Internal
	ID           int64        `db:"id"`
	DeploymentID DeploymentID `db:"deployment_id"`
	CreatedAt    time.Time    `db:"created_at"`
	UpdatedAt    time.Time    `db:"updated_at"`
}

type ServiceEvent added in v0.1.21

type ServiceEvent struct {
	ServiceName string
	Events      []Event
}

type ServiceLog added in v0.1.21

type ServiceLog struct {
	ServiceName string
	Logs        []Log
}

type ShellResponse added in v0.1.21

type ShellResponse struct {
	ExitCode int    `json:"exit_code"`
	Message  string `json:"message,omitempty"`
}

type SourceDownloadInfo added in v0.1.18

type SourceDownloadInfo struct {
	NodeID  string
	Address string
	Tk      *Token
}

type Storage added in v0.1.21

type Storage struct {
	Name       string `db:"name"`
	Quantity   int64  `db:"quantity"`
	Persistent bool   `db:"persistent"`
	Mount      string `db:"mount"`
}

type StorageStat added in v0.1.21

type StorageStat struct {
	MaxStorage uint64
	Available  uint64
	Active     uint64
	Pending    uint64
}

type StorageStats added in v0.1.11

type StorageStats struct {
	TotalSize    int64 `db:"total_storage_size"`
	UsedSize     int64 `db:"used_storage_size"`
	TotalTraffic int64 `db:"total_traffic"`
	EnableVIP    bool  `db:"enable_vip"`
	AssetCount   int   `db:"asset_count"`
}

StorageStats storage stats of user

type Storages added in v0.1.21

type Storages []*Storage

func (Storages) Scan added in v0.1.21

func (s Storages) Scan(value interface{}) error

func (Storages) Value added in v0.1.21

func (s Storages) Value() (driver.Value, error)

type SufficientResourceNode added in v0.1.21

type SufficientResourceNode struct {
	Name string
	ResourcesStatistics
}

type Token

type Token struct {
	ID string
	// CipherText encrypted TokenPayload by public key
	CipherText string
	// Sign signs CipherText by scheduler private key
	Sign string
}

Token access download asset

type TokenPayload

type TokenPayload struct {
	ID          string    `db:"token_id"`
	NodeID      string    `db:"node_id"`
	AssetCID    string    `db:"asset_id"`
	ClientID    string    `db:"client_id"`
	LimitRate   int64     `db:"limit_rate"`
	CreatedTime time.Time `db:"created_time"`
	Expiration  time.Time `db:"expiration"`
}

TokenPayload payload of token

type TunserverReq added in v0.1.21

type TunserverReq struct {
	IP     string
	AreaID string
}

type TunserverRsp added in v0.1.19

type TunserverRsp struct {
	URL    string
	NodeID string
}

type UploadInfo added in v0.1.19

type UploadInfo struct {
	List          []*NodeUploadInfo
	AlreadyExists bool
}

type UploadProgress added in v0.1.10

type UploadProgress struct {
	TotalSize int64
	DoneSize  int64
}

type UploadingAsset added in v0.1.10

type UploadingAsset struct {
	UserID          string
	TokenExpiration time.Time
	Progress        *UploadProgress
}

type UserAPIKeysInfo added in v0.1.11

type UserAPIKeysInfo struct {
	CreatedTime time.Time
	APIKey      string
}

type UserAccessControl added in v0.1.11

type UserAccessControl string
const (
	UserAPIKeyReadFile     UserAccessControl = "readFile"
	UserAPIKeyCreateFile   UserAccessControl = "createFile"
	UserAPIKeyDeleteFile   UserAccessControl = "deleteFile"
	UserAPIKeyReadFolder   UserAccessControl = "readFolder"
	UserAPIKeyCreateFolder UserAccessControl = "createFolder"
	UserAPIKeyDeleteFolder UserAccessControl = "deleteFolder"
)

type UserAssetDetail added in v0.1.11

type UserAssetDetail struct {
	UserID      string    `db:"user_id"`
	Hash        string    `db:"hash"`
	AssetName   string    `db:"asset_name"`
	AssetType   string    `db:"asset_type"`
	ShareStatus int64     `db:"share_status"`
	Expiration  time.Time `db:"expiration"`
	CreatedTime time.Time `db:"created_time"`
	TotalSize   int64     `db:"total_size"`
	Password    string    `db:"password"`
	GroupID     int       `db:"group_id"`
}

type UserAssetShareStatus added in v0.1.11

type UserAssetShareStatus int
const (
	UserAssetShareStatusUnshare UserAssetShareStatus = iota
	UserAssetShareStatusShared
	UserAssetShareStatusForbid
)

type UserAssetSummary added in v0.1.11

type UserAssetSummary struct {
	AssetOverview *AssetOverview
	AssetGroup    *AssetGroup
}

UserAssetSummary user asset and group

type UserInfo added in v0.1.11

type UserInfo struct {
	TotalSize     int64 `db:"total_storage_size"`
	UsedSize      int64 `db:"used_storage_size"`
	TotalTraffic  int64 `db:"total_traffic"`
	PeakBandwidth int64 `db:"peak_bandwidth"`
	DownloadCount int64 `db:"download_count"`
	EnableVIP     bool  `db:"enable_vip"`

	UpdateTime time.Time `db:"update_peak_time"`
}

type ValidationInfo

type ValidationInfo struct {
	NextElectionTime time.Time
}

ValidationInfo Validation, election related information

type ValidationResultInfo

type ValidationResultInfo struct {
	ID               int              `db:"id"`
	RoundID          string           `db:"round_id"`
	NodeID           string           `db:"node_id"`
	Cid              string           `db:"cid"`
	ValidatorID      string           `db:"validator_id"`
	BlockNumber      int64            `db:"block_number"` // number of blocks verified
	Status           ValidationStatus `db:"status"`
	Duration         int64            `db:"duration"` // validator duration, microsecond
	Bandwidth        float64          `db:"bandwidth"`
	StartTime        time.Time        `db:"start_time"`
	EndTime          time.Time        `db:"end_time"`
	Profit           float64          `db:"profit"`
	CalculatedProfit bool             `db:"calculated_profit"`
	TokenID          string           `db:"token_id"`
	FileSaved        bool             `db:"file_saved"`
	NodeCount        int              `db:"node_count"`
}

ValidationResultInfo validator result info

type ValidationStatus

type ValidationStatus int

ValidationStatus Validation Status

const (
	// ValidationStatusCreate  is the initial validation status when the validation process starts.
	ValidationStatusCreate ValidationStatus = iota
	// ValidationStatusSuccess is the validation status when the validation is success.
	ValidationStatusSuccess
	// ValidationStatusCancel is the validation status when the validation is canceled.
	ValidationStatusCancel

	// ValidationStatusNodeTimeOut is the validation status when the node times out.
	ValidationStatusNodeTimeOut
	// ValidationStatusValidateFail is the validation status when the validation fail.
	ValidationStatusValidateFail

	// ValidationStatusValidatorTimeOut is the validation status when the validator times out.
	ValidationStatusValidatorTimeOut
	// ValidationStatusGetValidatorBlockErr is the validation status when there is an error getting the blocks from validator.
	ValidationStatusGetValidatorBlockErr
	// ValidationStatusValidatorMismatch is the validation status when the validator mismatches.
	ValidationStatusValidatorMismatch

	// ValidationStatusLoadDBErr is the validation status when there is an error loading the database.
	ValidationStatusLoadDBErr
	// ValidationStatusCIDToHashErr is the validation status when there is an error converting a CID to a hash.
	ValidationStatusCIDToHashErr

	// ValidationStatusNodeOffline is the validation status when the node offline.
	ValidationStatusNodeOffline
)

type Workload

type Workload struct {
	SourceID     string
	DownloadSize int64
	CostTime     int64 // Millisecond
}

type WorkloadEvent added in v0.1.18

type WorkloadEvent int
const (
	WorkloadEventPull WorkloadEvent = iota
	WorkloadEventSync
	WorkloadEventRetrieve
)

type WorkloadRecord added in v0.1.10

type WorkloadRecord struct {
	WorkloadID    string         `db:"workload_id"`
	AssetCID      string         `db:"asset_cid"`
	ClientID      string         `db:"client_id"`
	AssetSize     int64          `db:"asset_size"`
	CreatedTime   time.Time      `db:"created_time"`
	ClientEndTime time.Time      `db:"client_end_time"`
	Workloads     []byte         `db:"workloads"`
	Status        WorkloadStatus `db:"status"`
	Event         WorkloadEvent  `db:"event"`
}

WorkloadReportRecord use to store workloadReport

type WorkloadRecordReq added in v0.1.18

type WorkloadRecordReq struct {
	WorkloadID string
	AssetCID   string
	Workloads  []Workload
}

WorkloadRecordReq use to store workloadReport

type WorkloadStatus added in v0.1.10

type WorkloadStatus int

WorkloadStatus Workload Status

const (
	// WorkloadStatusCreate is the initial workload status when the workload process starts.
	WorkloadStatusCreate WorkloadStatus = iota
	// WorkloadStatusSucceeded is the workload status when the workload is succeeded.
	WorkloadStatusSucceeded
	// WorkloadStatusFailed is the workload status when the workload is failed.
	WorkloadStatusFailed
	// WorkloadStatusInvalid is the workload status when the workload is invalid.
	WorkloadStatusInvalid
)

Jump to

Keyboard shortcuts

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