Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Add types for Bulk API response #14353

wants to merge 4 commits into from

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Oct 31, 2019

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.

return nil
}

type BulkResultItemInner struct {

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

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 {

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

// BulkOpType represents a valid bulk request op type
type BulkOpType string

var ErrInvalidBulkOpType = errors.New("invalid bulk optype in bulk result item")

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 {

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

Item BulkResultItemInner
}

var ErrInvalidBulkResultItem = errors.New("invalid bulk result item")

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

@ycombinator ycombinator changed the title Make types for Bulk API response Add types for Bulk API response Oct 31, 2019

type BulkItemErrorMsg string

func (b *BulkItemErrorMsg) UnmarshalJSON(j []byte) error {

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

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 {

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

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 {

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")

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

@ycombinator
Copy link
Contributor Author

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.

@ycombinator ycombinator deleted the libbeat-bulk-api-refactor branch December 25, 2019 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants