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

Cleanup Harvester and Input parts of Filebeat #1896

Merged
merged 1 commit into from
Jun 24, 2016

Conversation

ruflin
Copy link
Contributor

@ruflin ruflin commented Jun 22, 2016

  • Cleanup defaults by moving them to config
  • Move readers and sources into their own packages
  • Add some minor comments
  • Move state to its own package
  • Move multiline and json to its own file
  • Rename FileState to State as now package name is included

@ruflin ruflin force-pushed the harvester-cleanup branch from c368735 to daf409b Compare June 22, 2016 14:00
DefaultCloseOlder = 1 * time.Hour
DefaultForceCloseFiles = false
DefaultMaxBytes = 10 * (1 << 20) // 10MB
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need the consts if defaultConfig already contains all defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, removing it.

@ruflin ruflin force-pushed the harvester-cleanup branch from daf409b to 9f44c13 Compare June 22, 2016 15:07
// through a decoder converting the reader it's encoding to utf-8.
type LineSource struct {
reader *encoding.LineReader
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LineSource is basically an adapter for converting an io.Reader into a LineProcessor producing lines. Alternative names LinesAdapter or LineProducer. Perfectly valid to move LineSource into separate go file and only define interfaces in line.go.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For getting proper multiline json support one has to implement JsonProducer adapter wrapping io.Reader with json.Decoder. dealing with encoding might still be required, as golang requires UTF-8, but json can be UTF-16 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about LineEncoder as this is what it actually does?

@ruflin ruflin force-pushed the harvester-cleanup branch from 9f44c13 to 3d76bef Compare June 23, 2016 07:04
* Cleanup defaults by moving them to config
* Move readers and sources into their own packages
* Add some minor comments
* Move state to its own package
* Move multiline and json to its own file
* Rename FileState to State as now package name is included
* Adjust test cases
* Move multiline config to processor
* Move json to processor
* Separate limit and line processor
* Improve error handling in registrar
@ruflin ruflin force-pushed the harvester-cleanup branch from 3d76bef to 6ce744e Compare June 23, 2016 12:25
@ruflin
Copy link
Contributor Author

ruflin commented Jun 23, 2016

jenkins, retest it

1 similar comment
@ruflin
Copy link
Contributor Author

ruflin commented Jun 24, 2016

jenkins, retest it

@ruflin ruflin mentioned this pull request Jun 24, 2016
"github.com/elastic/beats/libbeat/common"
)

var (
defaultConfig = harvesterConfig{
BufferSize: cfg.DefaultHarvesterBufferSize,
DocumentType: cfg.DefaultDocumentType,
BufferSize: 16 << 10, // 16384
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I can read it, I like 16 * (1 << 10). Or give 1<<10 a name like, sz1K = (1<<10)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like time.Second would be nice. e.g. sizes.K or sizes.M.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the easiest solution here is to just write 16384. I don't think it 16 << 10 or any of the other variants brings a benefit.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's easier to get the number wrong when using 16384 over 16 * units.Kibi for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change it

@urso urso merged commit 08960d1 into elastic:master Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants