-
Notifications
You must be signed in to change notification settings - Fork 333
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 a maxQueueSize
configuration option
#765
Conversation
@@ -8,7 +8,7 @@ NSString *GenerateUUIDString(void); | |||
// Date Utils | |||
NSString *iso8601FormattedString(NSDate *date); | |||
|
|||
void trimQueue(NSMutableArray *array, int size); | |||
void trimQueue(NSMutableArray *array, NSUInteger size); |
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.
Did this to avoid an useless cast from NSUInteger
(long
on 64bits) to int
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.
Nice - can we add a test case for when a custom queue size is set?
Codecov Report
@@ Coverage Diff @@
## master #765 +/- ##
==========================================
+ Coverage 81% 85.43% +4.43%
==========================================
Files 54 52 -2
Lines 2785 2616 -169
==========================================
- Hits 2256 2235 -21
+ Misses 529 381 -148 |
@f2prateek pushed a test |
03a00f0
to
4b05b45
Compare
4b05b45
to
15eed6a
Compare
// before we add a new element. | ||
trimQueue(self.queue, 999); | ||
// Trim the queue to maxQueueSize - 1 before we add a new element. | ||
trimQueue(self.queue, self.analytics.configuration.maxQueueSize - 1); |
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 if somebody sets maxQueueSize
to 0?
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.
Oh, good catch! I guess we have to choose from one of these behaviours (ordered with what I think is best first) :
- forbid using
maxQueueSize = 0
and throw an error inmaxQueueSize
setter if 0 is set - when
maxQueueSize == 0
ignore all events - when
maxQueueSize == 0
behave likemaxQueueSize == 1
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.
Option 4: maxQueueSize == 0
should behave like a no-op, i.e. use the default setting.
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.
Option 5: Document that this must be > 1, and when maxQueueSize == 0
the behaviour is unspecified. I think this is reasonable for now.
/** | ||
* The maximum number of items to queue before starting to drop old ones. | ||
*/ | ||
@property (nonatomic, assign) NSUInteger maxQueueSize; |
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.
Can we also document the default value here?
Pushed improved docs @f2prateek |
hey @fathyb - think we might need a more complicated rebase here. I'll re-assign this back to you for now! |
7e9a433
to
a507953
Compare
a507953
to
51e00ab
Compare
Ref: LIB-442