-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 refresh period to monitor mw #1898
Conversation
@jfcg thx |
extended |
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.
.
ConfigDefault.Refresh = minRefresh | ||
} | ||
// update default index with new default title/refresh | ||
ConfigDefault.index = newIndex(ConfigDefault.Title, ConfigDefault.Refresh) |
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.
why don't we do this below when refresh and title has been reset or contains the default values ?
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 a user changes default config only, like:
monitor.ConfigDefault.Title = "New Title"
app.Get("/metrics", monitor.New())
then these lines will return default config directly:
// Return default config if nothing provided
if len(config) < 1 {
return ConfigDefault
}
so default config must be prepared beforehand 😉
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.
Why should the users do that?
Then they have not understood the concept or we should not expose the default config
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 can unexport default config, that would be easier but I think that decision should be considered for the whole project, not just for monitor mw.
Note that if something is exported to users, then it is part of the API and meant to be usable/modifiable.
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.
Though there does not seem to be many pablic uses of monitor.DefaultConfig
, as per Github search.
@@ -38,6 +39,9 @@ func Test_Monitor_Html(t *testing.T) { | |||
b, err := ioutil.ReadAll(resp.Body) | |||
utils.AssertEqual(t, nil, err) | |||
utils.AssertEqual(t, true, bytes.Contains(b, []byte("<title>"+defaultTitle+"</title>"))) | |||
timeoutLine := fmt.Sprintf("setTimeout(fetchJSON, %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.
please also create a test where the setting of the configuration and its modification is checked
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.
extended Test_Monitor_Html
to also check custom config.
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.
pls check my review comments
No description provided.