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

Add a maxQueueSize configuration option #765

Merged
merged 1 commit into from
Jul 16, 2018
Merged

Conversation

fathyb
Copy link
Contributor

@fathyb fathyb commented Jul 6, 2018

Ref: LIB-442

@fathyb fathyb requested a review from f2prateek July 6, 2018 14:52
@@ -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);
Copy link
Contributor Author

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

Copy link
Contributor

@f2prateek f2prateek left a 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-io
Copy link

codecov-io commented Jul 11, 2018

Codecov Report

Merging #765 into master will increase coverage by 4.43%.
The diff coverage is 93.1%.

@@            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

@fathyb
Copy link
Contributor Author

fathyb commented Jul 11, 2018

@f2prateek pushed a test

@fathyb fathyb force-pushed the feat/add/max-queue-size branch from 03a00f0 to 4b05b45 Compare July 12, 2018 10:48
@f2prateek f2prateek force-pushed the feat/add/max-queue-size branch from 4b05b45 to 15eed6a Compare July 12, 2018 21:24
// 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);
Copy link
Contributor

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?

Copy link
Contributor Author

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) :

  1. forbid using maxQueueSize = 0 and throw an error in maxQueueSize setter if 0 is set
  2. when maxQueueSize == 0 ignore all events
  3. when maxQueueSize == 0 behave like maxQueueSize == 1

Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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?

@fathyb
Copy link
Contributor Author

fathyb commented Jul 16, 2018

Pushed improved docs @f2prateek

@f2prateek
Copy link
Contributor

hey @fathyb - think we might need a more complicated rebase here. I'll re-assign this back to you for now!

@fathyb fathyb force-pushed the feat/add/max-queue-size branch from 7e9a433 to a507953 Compare July 16, 2018 19:25
@fathyb fathyb force-pushed the feat/add/max-queue-size branch from a507953 to 51e00ab Compare July 16, 2018 19:43
@f2prateek f2prateek merged commit 7331756 into master Jul 16, 2018
@f2prateek f2prateek deleted the feat/add/max-queue-size branch July 16, 2018 19:58
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.

3 participants