Documentation
¶
Index ¶
- Variables
- type AWSDataInfo
- type ActivationDetail
- type AssetGroup
- type AssetHash
- type AssetOverview
- type AssetProperty
- type AssetPullProgress
- type AssetRecord
- type AssetStateInfo
- type AssetStatistics
- type AssetStats
- type AssetStatus
- type AssetType
- type AuthUserUploadDownloadAsset
- type CandidateDownloadInfo
- type ConnectOptions
- type CreateAssetReq
- type CreateAssetRsp
- type DownloadHistory
- type EdgeDownloadInfo
- type EdgeDownloadInfoList
- type EventTopics
- type GeneratedCarInfo
- type InProgressAsset
- type JWTPayload
- type ListAssetGroupRsp
- type ListAssetRecordRsp
- type ListAssetSummaryRsp
- type ListDownloadRecordRsp
- type ListNodeAssetRsp
- type ListNodesRsp
- type ListReplicaEventRsp
- type ListReplicaRsp
- type ListRetrieveEventRsp
- type ListStorageStatsRsp
- type ListValidationResultRsp
- type ListWorkloadRecordRsp
- type MinioConfig
- type MinioUploadFileEvent
- type NatPunchReq
- type NatType
- type NodeActivation
- type NodeAssetInfo
- type NodeDynamicInfo
- type NodeIPInfo
- type NodeInfo
- type NodeReplicaRsp
- type NodeReplicaStatus
- type NodeSnapshot
- type NodeStatus
- type NodeType
- type NodeWorkloadReport
- type OpenRPCDocument
- type PullAssetReq
- type PullResult
- type RemoveAssetResult
- type ReplicaEvent
- type ReplicaEventInfo
- type ReplicaInfo
- type ReplicaStatus
- type RetrieveEvent
- type SchedulerCfg
- type StorageStats
- type Token
- type TokenPayload
- type UploadProgress
- type UploadingAsset
- type UserAPIKeysInfo
- type UserAccessControl
- type UserAssetDetail
- type UserAssetShareStatus
- type UserAssetSummary
- type UserInfo
- type ValidationInfo
- type ValidationResultInfo
- type ValidationStatus
- type Workload
- type WorkloadRecord
- type WorkloadReport
- type WorkloadStatus
Constants ¶
This section is empty.
Variables ¶
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
var ReplicaStatusAll = []ReplicaStatus{ ReplicaStatusWaiting, ReplicaStatusPulling, ReplicaStatusFailed, ReplicaStatusSucceeded, }
ReplicaStatusAll contains all possible replica statuses
var UserAccessControlAll = []UserAccessControl{ UserAPIKeyReadFile, UserAPIKeyCreateFile, UserAPIKeyDeleteFile, UserAPIKeyReadFolder, UserAPIKeyCreateFolder, UserAPIKeyDeleteFolder, }
Functions ¶
This section is empty.
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"`
}
AWSDataInfo aws data
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 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 AssetOverview ¶ added in v0.1.11
type AssetOverview struct {
AssetRecord *AssetRecord
UserAssetDetail *UserAssetDetail
VisitCount int
RemainVisitCount int
}
type AssetProperty ¶ added in v0.1.10
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 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/s
RetryCount int64 `db:"retry_count"`
ReplenishReplicas int64 `db:"replenish_replicas"`
ReplicaInfos []*ReplicaInfo
SPCount int64
}
AssetRecord represents information about an asset record
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 ¶
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 AuthUserUploadDownloadAsset ¶ added in v0.1.11
type CandidateDownloadInfo ¶
CandidateDownloadInfo represents download information for a candidate
type ConnectOptions ¶
type CreateAssetReq ¶ added in v0.1.10
type CreateAssetReq struct {
UserID string
AssetProperty
}
type CreateAssetRsp ¶ added in v0.1.10
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 EdgeDownloadInfo ¶
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 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 GeneratedCarInfo ¶ added in v0.1.10
type InProgressAsset ¶
InProgressAsset represents an asset that is currently being fetched, including its progress details.
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 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 ListNodesRsp ¶
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 MinioConfig ¶ added in v0.1.11
type MinioUploadFileEvent ¶ added in v0.1.11
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 // NatTypeFullCone Full cone NAT NatTypeFullCone // NatTypeRestricted Restricted NAT NatTypeRestricted // NatTypePortRestricted Port-restricted NAT NatTypePortRestricted )
func (NatType) FromString ¶
type NodeActivation ¶ added in v0.1.10
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 NodeDynamicInfo ¶ added in v0.1.10
type NodeDynamicInfo struct {
NodeID string `json:"node_id" form:"nodeId" gorm:"column:node_id;comment:;" db:"node_id"`
DiskUsage float64 `json:"disk_usage" form:"diskUsage" gorm:"column:disk_usage;comment:;" db:"disk_usage"`
CPUUsage float64
MemoryUsage float64
Status NodeStatus
IncomeIncr float64 // Base points increase every half hour (30 minute)
OnlineDuration int `db:"online_duration"` // unit:Minute
Profit float64 `db:"profit"`
LastSeen time.Time `db:"last_seen"`
DownloadTraffic int64 `db:"download_traffic"`
UploadTraffic int64 `db:"upload_traffic"`
AssetCount int64 `db:"asset_count"`
RetrieveCount int64 `db:"retrieve_count"`
}
NodeDynamicInfo Dynamic information about the node
type NodeIPInfo ¶ added in v0.1.11
NodeIPInfo
type NodeInfo ¶
type NodeInfo struct {
Type NodeType
ExternalIP string
InternalIP string
FirstTime time.Time `db:"first_login_time"`
BandwidthUp int64 `json:"bandwidth_up" db:"bandwidth_up"`
BandwidthDown int64 `json:"bandwidth_down" db:"bandwidth_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"`
NATType string `db:"nat_type"`
PortMapping string `db:"port_mapping"`
SchedulerID dtypes.ServerID `db:"scheduler_sid"`
DeactivateTime int64 `db:"deactivate_time"`
NodeDynamicInfo
}
NodeInfo contains information about a node.
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 NodeSnapshot ¶ added in v0.1.11
type NodeSnapshot struct {
NodeID string `db:"node_id"`
OnlineDuration int `db:"online_duration"` // unit:Minute
DiskUsage float64 `db:"disk_usage"`
LastSeen time.Time `db:"last_seen"`
BandwidthUp int64 `db:"bandwidth_up"`
BandwidthDown int64 `db:"bandwidth_down"`
Profit float64 `db:"profit"`
}
NodeSnapshot contains the real-time status information of a node, such as the last online time, online duration, CPU usage rate, and score changes.
type NodeStatus ¶ added in v0.1.10
type NodeStatus int
NodeStatus node status
const ( NodeOffline NodeStatus = iota NodeServicing NodeUnregister // Exceptions NodeNatSymmetric )
func (NodeStatus) String ¶ added in v0.1.10
func (n NodeStatus) String() string
type NodeType ¶
type NodeType int
NodeType node type
var RunningNodeType NodeType
RunningNodeType represents the type of the running node.
type NodeWorkloadReport ¶
type OpenRPCDocument ¶
type OpenRPCDocument map[string]interface{}
type PullAssetReq ¶
type PullAssetReq struct {
CID string
Replicas int64
Expiration time.Time
UserID string
Hash string
Bandwidth int64 // unit:MiB/s
SeedNodeID 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 RemoveAssetResult ¶
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"`
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"`
}
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 )
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 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 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 UploadProgress ¶ added in v0.1.10
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 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"`
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 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 ¶
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 )
type WorkloadRecord ¶ added in v0.1.10
type WorkloadRecord struct {
TokenPayload
Status WorkloadStatus `db:"status"`
ClientEndTime int64 `db:"client_end_time"`
ClientWorkload []byte `db:"client_workload"`
NodeWorkload []byte `db:"node_workload"`
}
WorkloadReportRecord use to store workloadReport
type 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 )