MCPcopy
hub / github.com/spacecloud-io/space-cloud / getServiceStatus

Function getServiceStatus

space-cli/cmd/modules/logs/getters.go:43–70  ·  view source on GitHub ↗
(project, commandName string, params map[string]string)

Source from the content-addressed store, hash-verified

41}
42
43func getServiceStatus(project, commandName string, params map[string]string) ([]string, error) {
44 // ReplicaInfo describes structure of replica info
45 type ReplicaInfo struct {
46 ID string `json:"id" yaml:"id"`
47 Status string `json:"status" yaml:"status"`
48 }
49 type ServiceStatus struct {
50 ServiceID string `json:"serviceId" yaml:"serviceId"`
51 Version string `json:"version" yaml:"version"`
52 DesiredReplicas interface{} `json:"desiredReplicas" yaml:"desiredReplicas"`
53 Replicas []*ReplicaInfo `json:"replicas" yaml:"replicas"`
54 }
55 type temp struct {
56 Error string `json:"error,omitempty"`
57 Result []*ServiceStatus `json:"result,omitempty"`
58 }
59 payload := new(temp)
60 if err := transport.Client.MakeHTTPRequest(http.MethodGet, fmt.Sprintf("/v1/runner/%s/services/status", project), params, payload); err != nil {
61 return nil, err
62 }
63 replicaIDs := make([]string, 0)
64 for _, serviceStatus := range payload.Result {
65 for _, replica := range serviceStatus.Replicas {
66 replicaIDs = append(replicaIDs, replica.ID)
67 }
68 }
69 return replicaIDs, nil
70}

Callers 1

GetSubCommandsFunction · 0.85

Calls 1

MakeHTTPRequestMethod · 0.65

Tested by

no test coverage detected