-
Notifications
You must be signed in to change notification settings - Fork 47
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
Added retry logic & batching settings #1
Conversation
The incorrect index error will only happen if an token is locked down to a specific index(es).
Specify the max number of retries when configuring a logger. The maximum backoff (time between retries) is capped at 2 minutes.
Also updated tests.
When this many events are in the contextQueue, flush() will be called.
|
||
// If batch interval is changed, update the config property | ||
if (this.config) { | ||
this.config.batchInterval = interval; |
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 do you need to do this?
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 _enableTimer(interval)
is called explicitly, we just store that interval value in the config. It could be removed
context = that._initializeContext(context); | ||
context.requestOptions.headers["Authorization"] = "Splunk " + context.config.token; | ||
|
||
if (isBatched) { |
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 also don't get this case here. Why do you distinguish between batch and unbatched?
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.
For isBatched we empty the entire queue, otherwise 1 event per request
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 understand what you're doing, I just don't understand why you're doing it. Why are you making a distinction here?
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.
fixed
* Configures an interval timer to flush any events in | ||
* <code>this.contextQueue</code> at the specified interval. | ||
* | ||
* param {Number} interval - The batch interval. |
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.
what measurement units do you use here? Milliseconds?
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.
yes & done
TODO: - Make some decisions about middleware - Update remaining examples - Add a few timer tests for 100% coverage - Added ability to have custom event formatter - Context no longer has config or requestOptions - If !autoflush and any batching settings, throw an error - Simplified logic in many places - Added several util functions - Updated tests - Clarified the basic.js example
All batch settings will be ignored when they are <= 0.
Added remaining tests for utils
We have collectively decided that this feature does not provide enough value at this time.
level: "info", | ||
autoFlush: true | ||
url: "https://localhost:8088", | ||
maxBatchCount: 1 // Send events 1 at a time |
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 do you need to set this?
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 none of the batch settings are configured, and autoFlush === true
(the default) it's basically not manual batching
context = this._initializeContext(context); | ||
|
||
// Store the context, and its estimated length | ||
this.contextQueue.push(context); |
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 do you need contextQueue
? This could easily be just an incremented number. You're storing a lot more memory this way.
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.
simplified, done
This change optimizes the flush() function since events will only be serialized once after passed to send(). Without middleware, we no longer need to store un-serialized objects.
To disable autoFlush behavior, set all batching settings to 0. It is still enabled by default - flushing events 1 by 1. Modify this behavior through the config object.
Closing this PR, opening another one with updated readme, examples and version numbers. |
No description provided.