-
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 registry for prospectors #4980
Conversation
feb2fad
to
7e00cfe
Compare
filebeat/crawler/crawler.go
Outdated
"github.com/elastic/beats/filebeat/registrar" | ||
"github.com/elastic/beats/libbeat/cfgfile" | ||
"github.com/elastic/beats/libbeat/common" | ||
"github.com/elastic/beats/libbeat/common/cfgwarn" | ||
"github.com/elastic/beats/libbeat/logp" | ||
|
||
_ "github.com/elastic/beats/filebeat/prospector" |
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.
in other places we use something like github.om/elastic/beats/<beatname>/include/list.go
, to build/provide an import list of 'plugins'.
It would be nice not to have a package named prospector
and another one named prospectors
. Rather have on prospector
package only if possible.
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.
Here is for example the script that generates the imports for metricbeat: https://github.com/elastic/beats/blob/master/metricbeat/scripts/generate_imports.py
"github.com/elastic/beats/libbeat/logp" | ||
) | ||
|
||
type ProspectorFactoryData 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.
how about naming it 'Context' or 'Environment'?
Keep in mind, the package names is part of a type its full. Try to reduce stuttering if possible. e.g.
prospectors.ProspectorFactory
can be minimized to prospectors.Factory
. And prospectors.ProspectorFactoryData
to prospectors.Context
.
BeatDone chan struct{} | ||
} | ||
|
||
type ProspectorFactory func(config *common.Config, outletFactory channel.OutleterFactory, data ProspectorFactoryData) (Prospectorer, 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.
appropos naming, I will not complain if you rename channel.OutleterFactory
to channel.Factory
;)
Just a few minor comments. All in all LGTM |
@@ -49,6 +50,13 @@ func NewProspector(cfg *common.Config, outletFactory channel.OutleterFactory) (* | |||
return p, nil | |||
} | |||
|
|||
func init() { |
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.
Could we always put the init functions on the top after the imports? I kind of like them at the top as it becomes also obvious they are executed first.
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 really great to have this. This will give us much more flexibility. I think we need to improve / fix the naming over time and it will probably become more obvious on what it should be when we start working with it.
7e00cfe
to
f51bc23
Compare
I addressed the notes. However, I am not satisfied with the package structure and names, but so far I don't have better idea. I also added renaming |
filebeat/prospector/include/list.go
Outdated
@@ -0,0 +1,8 @@ | |||
package include |
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 would suggest to move this directly under filebeat
instead of prospectr
as we ave it in other projects.
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 think we can keep iterating on the naming to get it right. I suggest to merge this feature now as it will give us new flexibility in adding prospector types.
@kvch There seem to be some issues with the tests. Ping me when you got the build green. |
cf521c9
to
e6eba4c
Compare
We still need the |
I will remove it \o/ |
e6eba4c
to
9fae267
Compare
I had to rename |
jenkins, test it |
@urso Never saw this Jenkins error before:
As the error is not related to this change, I think we can move forward here. |
@kvch Great job on this one. Lets now do small interations on top of it to potentially improve handling and even simplify things further. |
From now on it is possible to register prospectors in
init
functions, just like modules in Metricbeat.Example:
General
prospector
functions were moved toprospectors
package (for a lack of a better name). Inprospector.go
new prospectors should be imported to register.