Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshtin committed Dec 20, 2022
1 parent 68d3676 commit 81067a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package elasticsearch
import (
"context"
"encoding/json"
"errors"
"fmt"
"strings"
"sync/atomic"
Expand Down Expand Up @@ -217,8 +218,9 @@ func (p *processorImpl) bulkAfterAction(_ int64, requests []elastic.BulkableRequ
if err != nil {
const logFirstNRequests = 5
var httpStatus int
if err, isElasticErr := err.(*elastic.Error); isElasticErr {
httpStatus = err.Status
var esErr *elastic.Error
if errors.As(err, &esErr) {
httpStatus = esErr.Status
}

var logRequests strings.Builder
Expand Down
8 changes: 4 additions & 4 deletions service/worker/addsearchattributes/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func (a *activities) AddESMappingFieldActivity(ctx context.Context, params Workf
}

func (a *activities) isRetryableError(err error) bool {
var httpStatusCode int
if err, isElasticErr := err.(*elastic.Error); isElasticErr {
httpStatusCode = err.Status
var esErr *elastic.Error
if !errors.As(err, &esErr) {
return true
}

switch httpStatusCode {
switch esErr.Status {
case http.StatusBadRequest, http.StatusUnauthorized, http.StatusForbidden, http.StatusNotFound, http.StatusConflict:
return false
default:
Expand Down

0 comments on commit 81067a4

Please sign in to comment.