Skip to content
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

Merged
merged 3 commits into from May 31, 2017
Merged

rate limit #22

merged 3 commits into from May 31, 2017

Conversation

orthagonal
Copy link
Collaborator

No description provided.

test/log.test.js Outdated
let invocationCount = 0;
const logr = new Logr({
rateLimit: [
{ tags: ['tag1', 'tag2'], rate: 1000 }
Copy link
Member

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: {}
Copy link
Member

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

Copy link
Member

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

Copy link
Member

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: {},
Copy link
Member

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: []
}
},
Copy link
Member

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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clever :)

@orthagonal orthagonal merged commit 7691c7a into master May 31, 2017
@orthagonal orthagonal deleted the threshold branch May 31, 2017 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants