Skip to content

Commit

Permalink
Add unit test for es v7 bulk processor (#5764)
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-xie authored Mar 8, 2024
1 parent 82b298f commit a2e8540
Show file tree
Hide file tree
Showing 2 changed files with 428 additions and 5 deletions.
9 changes: 4 additions & 5 deletions common/elasticsearch/client/v7/client_bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (c *ElasticV7) runBulkProcessor(ctx context.Context, p *bulkProcessorParame
}, nil
}

func fromV7toGenericBulkResponse(response *elastic.BulkResponse) *bulk.GenericBulkResponse {
func fromV7ToGenericBulkResponse(response *elastic.BulkResponse) *bulk.GenericBulkResponse {
if response == nil {
return &bulk.GenericBulkResponse{}
}
Expand Down Expand Up @@ -166,12 +166,11 @@ func (c *ElasticV7) RunBulkProcessor(ctx context.Context, parameters *bulk.BulkP
}

afterFunc := func(executionId int64, requests []elastic.BulkableRequest, response *elastic.BulkResponse, err error) {
gerr := errorToGenericError(err)
parameters.AfterFunc(
executionId,
fromV7ToGenericBulkableRequests(requests),
fromV7toGenericBulkResponse(response),
gerr)
fromV7ToGenericBulkResponse(response),
convertV7ErrorToGenericError(err))
}

return c.runBulkProcessor(ctx, &bulkProcessorParametersV7{
Expand All @@ -185,7 +184,7 @@ func (c *ElasticV7) RunBulkProcessor(ctx context.Context, parameters *bulk.BulkP
AfterFunc: afterFunc,
})
}
func errorToGenericError(err error) *bulk.GenericError {
func convertV7ErrorToGenericError(err error) *bulk.GenericError {
if err == nil {
return nil
}
Expand Down
Loading

0 comments on commit a2e8540

Please sign in to comment.