-
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
Load the ES template on connect. #1381
Conversation
@urso would be good if you could check for side effects of this, or if you can think of a better way to implement it. I had to do two nested closures, so I'd like to simplify it if possible. Another issue is that currently |
@@ -61,6 +62,7 @@ func NewClient( | |||
esURL, index string, proxyURL *url.URL, tls *tls.Config, | |||
username, password string, | |||
params map[string]string, | |||
onConnectCallback *func(client *Client), |
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.
we've got so many parameters in NewClient already, we might consider to pass a config struct to clean this up a little. Pretty annoying to adjust tests every single parameter we add (even if not used by tests)
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.
onConnectCallback does not need to be a pointer to a function. Just use func (client *Client)
. One can check for == nil
and != nil
on func objects only.
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.
Cool, didn't know that.
I think error handling in loadTemplate is required. What if shield is available, and beats do not have rights to load template? |
400541c
to
bcb390c
Compare
Improvements since last review:
@urso, can you have another look? |
LGTM, but travis seems to complain. |
270ac1d
to
9439e4d
Compare
Rebased and added the Changelog item. The test failure in Jenkins doesn't seem related. |
jenkins, retest it |
It used to try loading it only once on init, causing bug elastic#1321. This change moves the call to loadTemplate at connection time, immediately after successful connection. This has the effect that if overwrite is true, the template will be loaded on each new established connection. The template is read on init time and sent to Elasticsearch at connect time. This means that if the template path is wrong, it will be discovered at startup (including `-configtest`). In case there is an error loading the template, the Connect call fails. This commit includes an integration test for the behaviour.
9439e4d
to
bc53cdb
Compare
It used to try loading it only once on init, causing bug #1321.
This change moves the call to loadTemplate at connection time, immediately
after successful connection. This has the effect that if overwrite is true,
the template will be loaded on each new established connection.