Browse Source

client增加http模式

pull/1/head
Sydonian 2 years ago
parent
commit
d4ee7caa4c
3 changed files with 70 additions and 20 deletions
  1. +11
    -16
      consts/consts.go
  2. +4
    -4
      consts/errorcode/error_code.go
  3. +55
    -0
      models/models.go

+ 11
- 16
consts/consts.go View File

@@ -1,31 +1,26 @@
package consts

const (
REDUNDANCY_REP = "rep"
REDUNDANCY_EC = "ec"
)

const (
IPFS_STATE_OK = "OK"
IPFSStateOK = "OK"

STORAGE_DIRECTORY_STATE_OK = "OK"
StorageDirectoryStateOK = "OK"

NODE_STATE_NORMAL = "Normal"
NODE_STATE_UNAVAILABLE = "Unavailable"
NodeStateNormal = "Normal"
NodeStateUnavailable = "Unavailable"
)

const (
OBJECT_STATE_NORMAL = "Normal"
OBJECT_STATE_DELETED = "Deleted"
ObjectStateNormal = "Normal"
ObjectStateDeleted = "Deleted"
)

const (
STORAGE_OBJECT_STATE_NORMAL = "Normal"
STORAGE_OBJECT_STATE_DELETED = "Deleted"
STORAGE_OBJECT_STATE_OUTDATED = "Outdated"
StorageObjectStateNormal = "Normal"
StorageObjectStateDeleted = "Deleted"
StorageObjectStateOutdated = "Outdated"
)

const (
CACHE_STATE_PINNED = "Pinned"
CACHE_STATE_TEMP = "Temp"
CacheStatePinned = "Pinned"
CacheStateTemp = "Temp"
)

+ 4
- 4
consts/errorcode/error_code.go View File

@@ -1,8 +1,8 @@
package errorcode

const (
OK = "OK"
OPERATION_FAILED = "OPERATION_FAILED"
TASK_NOT_FOUND = "TASK_NOT_FOUND"
OK = "OK"
OperationFailed = "OperationFailed"
BadArgument = "BadArgument"
TaskNotFound = "TaskNotFound"
)

+ 55
- 0
models/models.go View File

@@ -0,0 +1,55 @@
package models

/// TODO 将分散在各处的公共结构体定义集中到这里来

const (
RedundancyRep = "rep"
RedundancyEC = "ec"
)

type RedundancyConfigTypes interface{}
type RedundancyConfigTypesConst interface {
RepRedundancyConfig | ECRedundancyConfig
}
type RepRedundancyConfig struct {
RepCount int `json:"repCount"`
}

type ECRedundancyConfig struct {
}

type RedundancyDataTypes interface{}
type RedundancyDataTypesConst interface {
RepRedundancyData | ECRedundancyData
}
type RepRedundancyData struct {
FileHash string `json:"fileHash"`
}

func NewRedundancyRepData(fileHash string) RepRedundancyData {
return RepRedundancyData{
FileHash: fileHash,
}
}

type ECRedundancyData struct {
Blocks []ObjectBlock `json:"blocks"`
}

func NewECRedundancyData(blocks []ObjectBlock) ECRedundancyData {
return ECRedundancyData{
Blocks: blocks,
}
}

type ObjectBlock struct {
Index int `json:"index"`
FileHash string `json:"fileHash"`
}

func NewObjectBlock(index int, fileHash string) ObjectBlock {
return ObjectBlock{
Index: index,
FileHash: fileHash,
}
}

Loading…
Cancel
Save