MCPcopy
hub / github.com/cortexlabs/cortex / Awaken

Method Awaken

pkg/autoscaler/client.go:46–71  ·  view source on GitHub ↗
(api userconfig.Resource)

Source from the content-addressed store, hash-verified

44}
45
46func (c *client) Awaken(api userconfig.Resource) error {
47 payload, err := json.Marshal(api)
48 if err != nil {
49 return err
50 }
51
52 response, err := c.httpClient.Post(
53 urls.Join(c.endpoint, "/awaken"), "application/json", bytes.NewBuffer(payload),
54 )
55 if err != nil {
56 return err
57 }
58 defer func() { _ = response.Body.Close() }()
59
60 if response.StatusCode != http.StatusOK {
61 bodyBytes, _ := ioutil.ReadAll(response.Body)
62 errMsg := fmt.Sprintf("failed to awake api (status code %d)", response.StatusCode)
63 if bodyBytes != nil {
64 errMsg = errMsg + fmt.Sprintf(": %s", string(bodyBytes))
65 }
66
67 return fmt.Errorf(errMsg)
68 }
69
70 return nil
71}

Callers

nothing calls this directly

Calls 3

MarshalFunction · 0.92
JoinFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected