| @@ -230,8 +230,8 @@ type JobFilesUploadScheme struct { | |||
| } | |||
| type LocalFileUploadScheme struct { | |||
| LocalPath string `json:"localPath"` | |||
| UploadToCDSNodeID *cdssdk.NodeID `json:"uploadToCDSNodeID"` | |||
| LocalPath string `json:"localPath"` | |||
| UploadToCDSNodeID *cdssdk.HubID `json:"uploadToCDSNodeID"` | |||
| } | |||
| type JobServicesInfo struct { | |||
| @@ -244,10 +244,10 @@ type ServicePortInfo struct { | |||
| } | |||
| type JobSetServiceInfo struct { | |||
| Name string `json:"name"` | |||
| Port int64 `json:"port"` | |||
| CDSNodeID *cdssdk.NodeID `json:"cdsNodeID"` | |||
| LocalJobID string `json:"localJobID"` | |||
| Name string `json:"name"` | |||
| Port int64 `json:"port"` | |||
| CDSNodeID *cdssdk.HubID `json:"cdsNodeID"` | |||
| LocalJobID string `json:"localJobID"` | |||
| } | |||
| type Bootstrap interface { | |||
| @@ -8,18 +8,18 @@ import ( | |||
| "gitlink.org.cn/cloudream/common/utils/http2" | |||
| ) | |||
| var NodeGetNodesPath = "/node/getNodes" | |||
| var HubGetHubsPath = "/hub/getHubs" | |||
| type NodeGetNodesReq struct { | |||
| NodeIDs []cdssdk.NodeID `json:"nodeIDs"` | |||
| type HubGetHubsReq struct { | |||
| HubIDs []cdssdk.HubID `json:"hubIDs"` | |||
| } | |||
| type NodeGetNodesResp struct { | |||
| Nodes []cdssdk.Node `json:"nodes"` | |||
| type HubGetHubsResp struct { | |||
| Hubs []cdssdk.Hub `json:"hubs"` | |||
| } | |||
| func (c *Client) NodeGetNodes(req NodeGetNodesReq) (*NodeGetNodesResp, error) { | |||
| url, err := url.JoinPath(c.baseURL, NodeGetNodesPath) | |||
| func (c *Client) HubGetHubs(req HubGetHubsReq) (*HubGetHubsResp, error) { | |||
| url, err := url.JoinPath(c.baseURL, HubGetHubsPath) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -31,7 +31,7 @@ func (c *Client) NodeGetNodes(req NodeGetNodesReq) (*NodeGetNodesResp, error) { | |||
| return nil, err | |||
| } | |||
| jsonResp, err := ParseJSONResponse[response[NodeGetNodesResp]](resp) | |||
| jsonResp, err := ParseJSONResponse[response[HubGetHubsResp]](resp) | |||
| if err != nil { | |||
| return nil, err | |||
| } | |||
| @@ -33,9 +33,9 @@ type ObjectUpload struct { | |||
| } | |||
| type ObjectUploadInfo struct { | |||
| UserID cdssdk.UserID `json:"userID" binding:"required"` | |||
| PackageID cdssdk.PackageID `json:"packageID" binding:"required"` | |||
| NodeAffinity *cdssdk.NodeID `json:"nodeAffinity"` | |||
| UserID cdssdk.UserID `json:"userID" binding:"required"` | |||
| PackageID cdssdk.PackageID `json:"packageID" binding:"required"` | |||
| StorageAffinity cdssdk.StorageID `json:"storageAffinity"` | |||
| } | |||
| type UploadingObject struct { | |||
| @@ -53,12 +53,12 @@ func (c *Client) StorageLoadPackage(req StorageLoadPackageReq) (*StorageLoadPack | |||
| const StorageCreatePackagePath = "/storage/createPackage" | |||
| type StorageCreatePackageReq struct { | |||
| UserID cdssdk.UserID `json:"userID" binding:"required"` | |||
| StorageID cdssdk.StorageID `json:"storageID" binding:"required"` | |||
| Path string `json:"path" binding:"required"` | |||
| BucketID cdssdk.BucketID `json:"bucketID" binding:"required"` | |||
| Name string `json:"name" binding:"required"` | |||
| NodeAffinity *cdssdk.NodeID `json:"nodeAffinity"` | |||
| UserID cdssdk.UserID `json:"userID" binding:"required"` | |||
| StorageID cdssdk.StorageID `json:"storageID" binding:"required"` | |||
| Path string `json:"path" binding:"required"` | |||
| BucketID cdssdk.BucketID `json:"bucketID" binding:"required"` | |||
| Name string `json:"name" binding:"required"` | |||
| StorageAffinity cdssdk.StorageID `json:"storageAffinity"` | |||
| } | |||
| type StorageCreatePackageResp struct { | |||
| @@ -77,7 +77,7 @@ func Test_Object(t *testing.T) { | |||
| fileData[i] = byte(i) | |||
| } | |||
| nodeAff := cdssdk.NodeID(2) | |||
| stgAff := cdssdk.StorageID(2) | |||
| pkgName := uuid.NewString() | |||
| createResp, err := cli.Package().Create(PackageCreate{ | |||
| @@ -89,9 +89,9 @@ func Test_Object(t *testing.T) { | |||
| _, err = cli.Object().Upload(ObjectUpload{ | |||
| ObjectUploadInfo: ObjectUploadInfo{ | |||
| UserID: 1, | |||
| PackageID: createResp.Package.PackageID, | |||
| NodeAffinity: &nodeAff, | |||
| UserID: 1, | |||
| PackageID: createResp.Package.PackageID, | |||
| StorageAffinity: stgAff, | |||
| }, | |||
| Files: iterator.Array( | |||
| &UploadingObject{ | |||
| @@ -229,8 +229,8 @@ func Test_Cache(t *testing.T) { | |||
| }) | |||
| } | |||
| func Test_GetNodeInfos(t *testing.T) { | |||
| Convey("测试获取node信息", t, func() { | |||
| func Test_GetHubInfos(t *testing.T) { | |||
| Convey("测试获取hub信息", t, func() { | |||
| cli := NewClient(&Config{ | |||
| URL: "http://localhost:7890", | |||
| }) | |||
| @@ -13,7 +13,7 @@ const ( | |||
| ObjectPathSeparator = "/" | |||
| ) | |||
| type NodeID int64 | |||
| type HubID int64 | |||
| type PackageID int64 | |||
| @@ -193,28 +193,28 @@ func (Object) TableName() string { | |||
| return "Object" | |||
| } | |||
| type Node struct { | |||
| NodeID NodeID `gorm:"column:NodeID; primaryKey; type:bigint; autoIncrement" json:"nodeID"` | |||
| Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"` | |||
| Address NodeAddressInfo `gorm:"column:Address; type:json; serializer:union" json:"address"` | |||
| LocationID LocationID `gorm:"column:LocationID; type:bigint; not null" json:"locationID"` | |||
| State string `gorm:"column:State; type:varchar(255); not null" json:"state"` | |||
| LastReportTime *time.Time `gorm:"column:LastReportTime; type:datetime" json:"lastReportTime"` | |||
| type Hub struct { | |||
| HubID HubID `gorm:"column:HubID; primaryKey; type:bigint; autoIncrement" json:"hubID"` | |||
| Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"` | |||
| Address HubAddressInfo `gorm:"column:Address; type:json; serializer:union" json:"address"` | |||
| LocationID LocationID `gorm:"column:LocationID; type:bigint; not null" json:"locationID"` | |||
| State string `gorm:"column:State; type:varchar(255); not null" json:"state"` | |||
| LastReportTime *time.Time `gorm:"column:LastReportTime; type:datetime" json:"lastReportTime"` | |||
| } | |||
| func (Node) TableName() string { | |||
| return "Node" | |||
| func (Hub) TableName() string { | |||
| return "Hub" | |||
| } | |||
| type NodeAddressInfo interface { | |||
| type HubAddressInfo interface { | |||
| } | |||
| var NodeAddressUnion = types.NewTypeUnion[NodeAddressInfo]( | |||
| var HubAddressUnion = types.NewTypeUnion[HubAddressInfo]( | |||
| (*GRPCAddressInfo)(nil), | |||
| (*HttpAddressInfo)(nil), | |||
| ) | |||
| var _ = serder.UseTypeUnionInternallyTagged(&NodeAddressUnion, "type") | |||
| var _ = serder.UseTypeUnionInternallyTagged(&HubAddressUnion, "type") | |||
| type GRPCAddressInfo struct { | |||
| serder.Metadata `union:"GRPC"` | |||
| @@ -233,8 +233,8 @@ type HttpAddressInfo struct { | |||
| Port int `json:"port"` | |||
| } | |||
| func (n Node) String() string { | |||
| return fmt.Sprintf("%v(%v)", n.Name, n.NodeID) | |||
| func (n Hub) String() string { | |||
| return fmt.Sprintf("%v(%v)", n.Name, n.HubID) | |||
| } | |||
| type PinnedObject struct { | |||
| @@ -257,15 +257,15 @@ func (Bucket) TableName() string { | |||
| return "Bucket" | |||
| } | |||
| type NodeConnectivity struct { | |||
| FromNodeID NodeID `gorm:"column:FromNodeID; primaryKey; type:bigint" json:"fromNodeID"` | |||
| ToNodeID NodeID `gorm:"column:ToNodeID; primaryKey; type:bigint" json:"ToNodeID"` | |||
| Delay *float32 `gorm:"column:Delay; type:float" json:"delay"` | |||
| TestTime time.Time `gorm:"column:TestTime; type:datetime" json:"testTime"` | |||
| type HubConnectivity struct { | |||
| FromHubID HubID `gorm:"column:FromHubID; primaryKey; type:bigint" json:"fromHubID"` | |||
| ToHubID HubID `gorm:"column:ToHubID; primaryKey; type:bigint" json:"ToHubID"` | |||
| Delay *float32 `gorm:"column:Delay; type:float" json:"delay"` | |||
| TestTime time.Time `gorm:"column:TestTime; type:datetime" json:"testTime"` | |||
| } | |||
| func (NodeConnectivity) TableName() string { | |||
| return "NodeConnectivity" | |||
| func (HubConnectivity) TableName() string { | |||
| return "HubConnectivity" | |||
| } | |||
| type StoragePackageCachingInfo struct { | |||
| @@ -11,7 +11,7 @@ type Storage struct { | |||
| StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint; autoIncrement;"` | |||
| Name string `json:"name" gorm:"column:Name; type:varchar(256); not null"` | |||
| // 完全管理此存储服务的Hub的ID | |||
| MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; type:bigint; not null"` | |||
| MasterHub HubID `json:"masterHub" gorm:"column:MasterHub; type:bigint; not null"` | |||
| // 存储服务的地址,包含鉴权所需数据 | |||
| Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"` | |||
| // 存储服务拥有的特别功能 | |||