PreEmptive Analytics iOS API  2.0
The official iOS API for sending PreEmptive Analytics data.
PADefaultFlowController Class Reference

The default flow controller. More...

Inheritance diagram for PADefaultFlowController:
<PAFlowController>

Instance Methods

(id) - init
 Initializes the flow controller with default values. More...
 
(id) - initWithConfiguration:
 Initializes the flow controller with values from configuration. More...
 
(NSUInteger) - getInterval:
 Calculates the time to wait until the next automatic batching and sending of messages. More...
 
(NSUInteger) - messagesToDrop:
 The number of messages to drop based in the current count. More...
 
(BOOL) - okToTransmit
 Determines if message sending is currently permitted. More...
 
(void) - onSend:
 Updates the flow controller based on the success or failure of a message transmission. More...
 
(BOOL) - hasBatchExpired:attempts:
 Determines if a stored messages batch has expired and is eligible for deletion/dropping. More...
 

Properties

NSUInteger gain
 The rate at which the interval should be changed in relation to the number of messages queued. More...
 
NSUInteger quietGain
 The rate at which the interval should be changed when the queue is empty. More...
 
NSUInteger maximumSequentialFailureCount
 The maximum number of sequential transmission failures before waiting the duration of the retryTimeout to retry sending.
 
NSUInteger retryTimeout
 The number of milliseconds to wait before allowing transmissions after a series of sequential failures.
 
- Properties inherited from <PAFlowController>
NSUInteger queueSize
 The maximum number of messages that can be held in the queue.
 
NSUInteger highWater
 The point at which queued messages should be batched and sent. More...
 
NSUInteger minimumInterval
 The minimum amout of time the transmitter should wait between checking the message queue specified in milliseconds.
 
NSUInteger maximumInterval
 The maximum amout of time the transmitter should wait between checking the message queue specified in milliseconds.
 
BOOL offline
 Is the transmission of messages prohibited?
 
BOOL sendDisabled
 Is the transmission of messages temporarily disabled? More...
 
BOOL supportOfflineStorage
 Is offline storage of messages permitted?
 
NSUInteger maximumBatchSize
 The maximum size (in bytes) of a message batch. More...
 
NSUInteger minimumFailureCount
 The minimum amount of times a message should be attempted to be sent before becoming eligible for deletion from offline storage.
 
NSUInteger minimumTimeToLive
 The minimum age(in seconds) a message must be before it becomes eligible for deletion from offline storage.
 

Detailed Description

The default flow controller.

The default values are:

  • queueSize: 30u
  • highWater: 20u
  • maximumInterval: 30000u (30 seconds)
  • minimumInterval: 1u (1 millisecond)
  • gain: 66u
  • quietGain: 33u
  • offline: NO
  • supportOfflineStorage: YES
  • sendDisabled: NO
  • maximumSequentialFailureCount: 3u
  • retryTimeout: 60000u (60 seconds)
  • maximumBatchSize: 4194304u (4MB)
  • minimumFailureCount: 150u
  • minimumTimeToLive: 259200u (3 days)

Definition at line 28 of file PADefaultFlowController.h.

Method Documentation

- (NSUInteger) getInterval: (NSUInteger)  numberOfMessages

Calculates the time to wait until the next automatic batching and sending of messages.

It should return a value between minimumInterval and maximumInterval based on history of the number of messages being sent and the queueSize. Gain and quietGain are used to decrease/increase the interval.

Parameters
numberOfMessagesThe number of messages just batched and sent.
Returns
The time interval to wait in milliseconds.

Reimplemented from <PAFlowController>.

- (BOOL) hasBatchExpired: (NSDate *)  date
attempts: (NSUInteger)  attempts 

Determines if a stored messages batch has expired and is eligible for deletion/dropping.

This takes into account minimumFailureCount and minimumTimeToLive.

Parameters
dateThe creation date of the batch.
attemptsThe number of transmission attempts.
Returns
YES if it has expired.

Reimplemented from <PAFlowController>.

- (id) init

Initializes the flow controller with default values.

Returns
An initialized flow controller
- (id) initWithConfiguration: (PAConfiguration *)  config

Initializes the flow controller with values from configuration.

When a flow controller is not provided to a PAClient it uses this method to initalize the default flow controller.

Parameters
configThe configuration. The following parameters are used: offline, sendDisabled, supportOfflineStorage, maximumBatchSize, minimumTimeToLive, and minimumFailureCount. All other values use the defaults.
Returns
An initialized flow controller.
See also
PAClient
- (NSUInteger) messagesToDrop: (NSUInteger)  currentMessageCount

The number of messages to drop based in the current count.

Those above the queueSize will be dropped.

Parameters
currentMessageCountThe current number of messages.
Returns
The number of messages to drop

Reimplemented from <PAFlowController>.

- (BOOL) okToTransmit

Determines if message sending is currently permitted.

This takes the follwing properties into account: online, sendDisabled, maximumSequentialFailureCount and retryTimeout.

Returns
YES If it is ok to transmit.

Reimplemented from <PAFlowController>.

- (void) onSend: (BOOL)  sendSucceeded

Updates the flow controller based on the success or failure of a message transmission.

This impacts the retryTimeout based on the maximumSequentialFailureCount.

Parameters
sendSucceededWas the transmission successful?

Reimplemented from <PAFlowController>.

Property Documentation

- (NSUInteger) gain
readwritenonatomicassign

The rate at which the interval should be changed in relation to the number of messages queued.

This is an integer greater than zero that acts as a percentage.

Definition at line 33 of file PADefaultFlowController.h.

- (NSUInteger) quietGain
readwritenonatomicassign

The rate at which the interval should be changed when the queue is empty.

This is an integer greater than zero and greater than or equal to 100 that acts as a percentage.

Definition at line 38 of file PADefaultFlowController.h.


The documentation for this class was generated from the following file: