-
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
Combine libbeat/beat and libbeat/publisher/beat package + move all beat instance handling to libbeat/cmd package #4821
Conversation
- only have commonly shared structs/interfaces in libbeat/beat - move libbeat/beat functionality to libbeat/cmd/instance package - update imports/dependencies - start hiding some exported symbols
- move beat.Client, beat.Event, beat.Pipeline to libbeat/beat - move some shared config objects from beat.BeatConfig to private cmd/instance package where easily possible (fix import cycles)
c32b0e7
to
ebcf8dd
Compare
"github.com/elastic/beats/libbeat/common" | ||
"github.com/elastic/beats/libbeat/logp" | ||
"github.com/elastic/beats/libbeat/publisher/beat" | ||
|
||
"github.com/elastic/beats/filebeat/harvester" |
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.
do you started to separate filebeat
from libbeat
imports on purpose?
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.
yes :)
I did find it weird for filebeat having import order filebeat>libbeat and for packetbeat it being the other way around.
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.
@andrewkroh WDYT? Can we automate that? :-D
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.
Yes, but not with the standard goimports
. It would take a customization to goimports
, which isn't a bad idea, it would just take a little time.
@@ -1,6 +1,6 @@ | |||
// +build !integration | |||
|
|||
package beat | |||
package instance |
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.
If we have an instance
package, it would kind of make sense to have this under the beat
package?
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.
I put it in libbeat/cmd, as the instance
package is used by almost all commands defined in libbeat/cmd. This way all code required or requiring a beat instance is combined in libbeat/cmd.
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.
Some more cleanup on instance or cmd package would be nice. But this was nothing I wanted to touch right now.
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.
Yeah, also see some other cleanups coming but this is big enough already :-)
@@ -1,39 +0,0 @@ | |||
package beater |
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.
I like this change but not sure how it is related to the rest of the changes?
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.
it's mostly for sanity, as I wanted the libbeat/cmd/instance
module to be used only internally. The -devices
flag always has been a pretty ugly hack, generating some dependency between the beat and some weird global access to libbeat internals.
In general I like the changes you made. I'm not a big fan of the It seems some other cleanups / improvements sneaked into this PR like Winlogbeat Settings or packetbeat device removal. As this is a major change in how beats are setup and will break all community beats I would like to see the unrelated changes in other PR's if possible. This will make it much easier later to follow which things belonged together. For example for the device removal the changelog will link to the PR that only did this. |
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.
LGTM. I left some comments about the pre-existing godocs.
libbeat/beat/beat.go
Outdated
) | ||
|
||
// Creator initializes and configures a new Beater instance used to execute | ||
// the beat its run-loop. |
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.
s/beat its/beat's/
libbeat/beat/beat.go
Outdated
|
||
SetupMLCallback SetupMLCallback // setup callback for ML job configs | ||
InSetupCmd bool // this is set to true when the `setup` command is called | ||
|
||
// XXX: remove Config from public interface |
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.
It would be nice to include in the comment what's blocking this from happening or when it can be done.
libbeat/beat/beat.go
Outdated
// XXX: remove Config from public interface | ||
Config *BeatConfig // Common Beat configuration data. | ||
|
||
BeatConfig *common.Config // The beats it's own configuration section |
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.
s/beats it's/beat's/
libbeat/beat/info.go
Outdated
|
||
import "github.com/satori/go.uuid" | ||
|
||
// BeatInfo stores a beats instance meta data. | ||
type BeatInfo struct { | ||
type Info struct { | ||
Beat string // The actual beat its name |
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.
s/beat its/beat's/
winlogbeat/beater/winlogbeat.go
Outdated
@@ -49,21 +48,19 @@ func New(b *beat.Beat, _ *common.Config) (beat.Beater, error) { | |||
// XXX: winlogbeat validates top-level config -> ignore beater config and |
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.
This comment can be removed now that I removed the validation code.
winlogbeat/config/config.go
Outdated
@@ -23,26 +23,12 @@ type Validator interface { | |||
Validate() 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.
Can this interface be removed too? I think it predates ucfg.
IgnoreOlder time.Duration `config:"ignore_older"` | ||
ReadBufferSize uint `config:"read_buffer_size" validate:"min=1"` | ||
FormatBufferSize uint `config:"format_buffer_size" validate:"min=1"` | ||
Raw map[string]interface{} `config:",inline"` |
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.
Not sure what raw
was doing but want to make sure it didn't disappear by accident.
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.
I guess it used to be for additional 'validation' on allowed settings. But it's not used anymore in any place, so I removed it.
This PR moves some types and functionality to
libbeat/beat
andlibbeat/cmd
. Thelibbeat/beat
package only defines some common/important types and interfaces to be used by actual beats, without providing real implementations. With these changes, thepublisher/libbeat/beat
finally could be fully merged intolibbeat/beat
For examplebeat.Client
,beat.Pipeline
,beat.Info
, .... Setting up a beats instance is moved tolibbeat/cmd/instance
package (due to lack of a better name), as the different commands implemented bylibbeat/cmd
do rely on a shared view of an actual configured instance. The move was also required to resolve quite a number of circular imports, as theinstance
package basically needs to import all other libbeat packages (directly/indirectly) in order to setup a working beat.Setting up and running a beat instance is still somewhat complicated. Did keep me quite busy in hunting chicken and eggs. Let's see if we can refine/cleanup this somewhat more in later PRs.
libbeat/publisher/beat
tolibbeat/beat
libbeat/beat
defines shared type/interfaces between libbeat and the actual beat => reduce public interface (exports) inlibbeat/beat
to fields/types really being used/sharedpacketbeat -device
in favor ofpacketbeat device
. Removes some clunky hack we used to have for supporting the-device
flag.common.BeatInfo
tobeat.Info