(messageBody string, isOnJobComplete bool)
| 112 | } |
| 113 | |
| 114 | func (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 | |
| 146 | func (h *BatchMessageHandler) handleBatch(message *sqs.Message) error { |
| 147 | h.log.Infow("processing batch", "id", *message.MessageId) |
no test coverage detected