| @@ -3,4 +3,9 @@ package imsdk | |||||
| const ( | const ( | ||||
| EnvPackageList = "IMFS_PACKAGE_LIST" | EnvPackageList = "IMFS_PACKAGE_LIST" | ||||
| EnvServiceAddress = "IMFS_SERVICE_ADDRESS" | EnvServiceAddress = "IMFS_SERVICE_ADDRESS" | ||||
| EnvLocalJobID = "LOCAL_JOB_ID" | |||||
| EnvJobsetID = "JOBSET_ID" | |||||
| EnvClientServiceList = "CLENT_SERVICE_LIST" | |||||
| EnvServerServiceList = "SERVER_SERVICE_LIST" | |||||
| ) | ) | ||||
| @@ -0,0 +1,45 @@ | |||||
| package imsdk | |||||
| import ( | |||||
| "net/url" | |||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | |||||
| schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | |||||
| ) | |||||
| const ProxyGetServiceInfoPath = "/proxy/getServiceInfo" | |||||
| type ProxyGetServiceInfo struct { | |||||
| ServiceName string `json:"serviceName"` | |||||
| JobSetID schsdk.JobSetID `json:"jobSetID"` | |||||
| } | |||||
| type ProxyGetServiceInfoResp struct { | |||||
| LocalJobID string `json:"localJobID"` | |||||
| } | |||||
| func (c *Client) ProxyGetJobID(req ProxyGetServiceInfo) (*ProxyGetServiceInfoResp, error) { | |||||
| url, err := url.JoinPath(c.baseURL, ProxyGetServiceInfoPath) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| resp, err := myhttp.GetForm(url, myhttp.RequestParam{ | |||||
| Query: req, | |||||
| }) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| jsonResp, err := myhttp.ParseJSONResponse[response[ProxyGetServiceInfoResp]](resp) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if jsonResp.Code == errorcode.OK { | |||||
| return &jsonResp.Data, nil | |||||
| } | |||||
| return nil, jsonResp.ToError() | |||||
| } | |||||
| @@ -114,6 +114,18 @@ type Object struct { | |||||
| Redundancy Redundancy `db:"Redundancy" json:"redundancy"` | Redundancy Redundancy `db:"Redundancy" json:"redundancy"` | ||||
| } | } | ||||
| type Node struct { | |||||
| NodeID NodeID `db:"NodeID" json:"nodeID"` | |||||
| Name string `db:"Name" json:"name"` | |||||
| LocalIP string `db:"LocalIP" json:"localIP"` | |||||
| ExternalIP string `db:"ExternalIP" json:"externalIP"` | |||||
| LocalGRPCPort int `db:"LocalGRPCPort" json:"localGRPCPort"` | |||||
| ExternalGRPCPort int `db:"ExternalGRPCPort" json:"externalGRPCPort"` | |||||
| LocationID LocationID `db:"LocationID" json:"locationID"` | |||||
| State string `db:"State" json:"state"` | |||||
| LastReportTime *time.Time `db:"LastReportTime" json:"lastReportTime"` | |||||
| } | |||||
| type PinnedObject struct { | type PinnedObject struct { | ||||
| ObjectID ObjectID `db:"ObjectID" json:"objectID"` | ObjectID ObjectID `db:"ObjectID" json:"objectID"` | ||||
| NodeID NodeID `db:"NodeID" json:"nodeID"` | NodeID NodeID `db:"NodeID" json:"nodeID"` | ||||
| @@ -0,0 +1,43 @@ | |||||
| package cdssdk | |||||
| import ( | |||||
| "net/url" | |||||
| "gitlink.org.cn/cloudream/common/consts/errorcode" | |||||
| myhttp "gitlink.org.cn/cloudream/common/utils/http" | |||||
| ) | |||||
| var NodeGetNodesPath = "/node/getNodes" | |||||
| type NodeGetNodesReq struct { | |||||
| NodeIDs []NodeID `json:"nodeIDs"` | |||||
| } | |||||
| type NodeGetNodesResp struct { | |||||
| Nodes []Node `json:"nodes"` | |||||
| } | |||||
| func (c *Client) NodeGetNodes(req NodeGetNodesReq) (*NodeGetNodesResp, error) { | |||||
| url, err := url.JoinPath(c.baseURL, NodeGetNodesPath) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| resp, err := myhttp.GetForm(url, myhttp.RequestParam{ | |||||
| Query: req, | |||||
| }) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| jsonResp, err := myhttp.ParseJSONResponse[response[NodeGetNodesResp]](resp) | |||||
| if err != nil { | |||||
| return nil, err | |||||
| } | |||||
| if jsonResp.Code == errorcode.OK { | |||||
| return &jsonResp.Data, nil | |||||
| } | |||||
| return nil, jsonResp.ToError() | |||||
| } | |||||