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
rate limit #22
rate limit #22
Conversation
test/log.test.js
Outdated
let invocationCount = 0; | ||
const logr = new Logr({ | ||
rateLimit: [ | ||
{ tags: ['tag1', 'tag2'], rate: 1000 } |
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 talked in slack how this won't work
index.js
Outdated
@@ -14,13 +14,14 @@ const defaults = { | |||
reporterDefaults: { | |||
filter: [], | |||
exclude: [] | |||
} | |||
}, | |||
rateLimit: {} |
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.
rate limit should be reporter specific
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.
so move into reporter defaults. also should be a number and maybe a rateLimitBasedOnTags: true
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.
Maybe we rename rateLimit to throttle: 1000. So it would only log one a second
index.js
Outdated
@@ -13,14 +13,15 @@ const defaults = { | |||
reporters: null, | |||
reporterDefaults: { | |||
filter: [], | |||
throttle: {}, |
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.
lets do two separate options to make it more explicit.
throttle: false, throttleBasedOnTags: false
index.js
Outdated
exclude: [] | ||
} | ||
}, |
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.
trailing comma
index.js
Outdated
@@ -190,6 +191,17 @@ class Logger { | |||
if (options.exclude.length !== 0 && intersection(options.exclude, tags).length > 0) { | |||
return; | |||
} | |||
// if throttling was specified then throttle log rate: | |||
if (Object.keys(options.throttle).length > 0) { | |||
const tagKey = options.throttle.throttleBasedOnTags ? tags.join('') : 'all'; |
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.
clever :)
No description provided.