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

Method submitRequest

pkg/dequeuer/batch_handler.go:114–144  ·  view source on GitHub ↗
(messageBody string, isOnJobComplete bool)

Source from the content-addressed store, hash-verified

112}
113
114func (h *BatchMessageHandler) submitRequest(messageBody string, isOnJobComplete bool) error {
115 targetURL := h.config.TargetURL
116 if isOnJobComplete {
117 targetURL = urls.Join(targetURL, "/on-job-complete")
118 }
119
120 req, err := http.NewRequest(http.MethodPost, targetURL, bytes.NewBuffer([]byte(messageBody)))
121 if err != nil {
122 return errors.WithStack(err)
123 }
124
125 req.Header.Set("Content-Type", "application/json")
126 req.Header.Set(CortexJobIDHeader, h.config.JobID)
127 response, err := h.httpClient.Do(req)
128 if err != nil {
129 return ErrorUserContainerNotReachable(err)
130 }
131 defer func() {
132 _ = response.Body.Close()
133 }()
134
135 if response.StatusCode == http.StatusNotFound && isOnJobComplete {
136 return nil
137 }
138
139 if response.StatusCode != http.StatusOK {
140 return ErrorUserContainerResponseStatusCode(response.StatusCode)
141 }
142
143 return nil
144}
145
146func (h *BatchMessageHandler) handleBatch(message *sqs.Message) error {
147 h.log.Infow("processing batch", "id", *message.MessageId)

Callers 2

handleBatchMethod · 0.95
onJobCompleteMethod · 0.95

Calls 5

JoinFunction · 0.92
WithStackFunction · 0.92
SetMethod · 0.80

Tested by

no test coverage detected