-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add types for Bulk API response #14353
Conversation
libbeat/outputs/elasticsearch/api.go
Outdated
return nil | ||
} | ||
|
||
type BulkResultItemInner struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type BulkResultItemInner should have comment or be unexported
libbeat/outputs/elasticsearch/api.go
Outdated
var ErrInvalidBulkOpType = errors.New("invalid bulk optype in bulk result item") | ||
var bulkOpTypes = map[string]bool{"create": true, "index": true, "update": true, "delete": true} | ||
|
||
func (b *BulkOpType) UnmarshalJSON(j []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method BulkOpType.UnmarshalJSON should have comment or be unexported
libbeat/outputs/elasticsearch/api.go
Outdated
// BulkOpType represents a valid bulk request op type | ||
type BulkOpType string | ||
|
||
var ErrInvalidBulkOpType = errors.New("invalid bulk optype in bulk result item") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported var ErrInvalidBulkOpType should have comment or be unexported
|
||
var ErrInvalidBulkResultItem = errors.New("invalid bulk result item") | ||
|
||
func (b *BulkResultItem) UnmarshalJSON(j []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method BulkResultItem.UnmarshalJSON should have comment or be unexported
libbeat/outputs/elasticsearch/api.go
Outdated
Item BulkResultItemInner | ||
} | ||
|
||
var ErrInvalidBulkResultItem = errors.New("invalid bulk result item") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported var ErrInvalidBulkResultItem should have comment or be unexported
|
||
type BulkItemErrorMsg string | ||
|
||
func (b *BulkItemErrorMsg) UnmarshalJSON(j []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method BulkItemErrorMsg.UnmarshalJSON should have comment or be unexported
Error BulkItemErrorMsg `json:"error"` | ||
} | ||
|
||
type BulkItemErrorMsg string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type BulkItemErrorMsg should have comment or be unexported
|
||
type BulkItemErrorMsg string | ||
|
||
func (b *BulkItemErrorMsg) UnmarshalJSON(j []byte) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method BulkItemErrorMsg.UnmarshalJSON should have comment or be unexported
Error BulkItemErrorMsg `json:"error"` | ||
} | ||
|
||
type BulkItemErrorMsg string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type BulkItemErrorMsg should have comment or be unexported
return nil | ||
} | ||
|
||
type BulkResultItemInner struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type BulkResultItemInner should have comment or be unexported
@@ -27,6 +27,11 @@ import ( | |||
"github.com/elastic/beats/libbeat/common" | |||
) | |||
|
|||
var ( | |||
ErrInvalidBulkResultItem = errors.New("invalid bulk result item") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported var ErrInvalidBulkResultItem should have comment or be unexported
The benchmark tests reported about 9-10x slowdown in the JSON parsing with this PR (expectedly as it has to perform a lot more allocations along the way). So I'm going to close this PR unmerged. |
This is a refactoring PR that implements golang types to represent various parts of an Elasticsearch Bulk API response. This removes the need for
elasticsearch.bulkCollectPublishFails
to perform a bunch of byte-level parsing of the Bulk API response.