Skip to content

Commit 01d622c

Browse files
fix for event dispatcher batch size
1 parent 6157806 commit 01d622c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

OptimizelySDK/Customization/DefaultEventDispatcher.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ open class DefaultEventDispatcher : BackgroundingCallbacks, OPTEventDispatcher {
2828
static let MAX_FAILURE_COUNT = 3
2929

3030
// default timerInterval
31-
open var timerInterval:TimeInterval = 60 * 5 // every five minutes
31+
var timerInterval:TimeInterval = 60 * 5 // every five minutes
3232
// default batchSize.
3333
// attempt to send events in batches with batchSize number of events combined
34-
open var batchSize:Int = 10
34+
var batchSize:Int = 10
3535
// start trimming the front of the queue when we get to over maxQueueSize
3636
// TODO: implement
37-
open var maxQueueSize:Int = 3000
37+
var maxQueueSize:Int = 30000
3838

3939
lazy var logger = HandlerRegistryService.shared.injectLogger()
4040
var backingStore:DataStoreType = .file
@@ -47,9 +47,8 @@ open class DefaultEventDispatcher : BackgroundingCallbacks, OPTEventDispatcher {
4747
// timer as a atomic property.
4848
var timer:AtomicProperty<Timer> = AtomicProperty<Timer>()
4949

50-
public init(batchSize:Int = 10, maxQueueSize:Int = 3000, backingStore:DataStoreType = .file, dataStoreName:String = "OPTEventQueue", timerInterval:TimeInterval = 60*5 ) {
51-
self.batchSize = batchSize
52-
self.maxQueueSize = maxQueueSize
50+
public init(batchSize:Int = 10, backingStore:DataStoreType = .file, dataStoreName:String = "OPTEventQueue", timerInterval:TimeInterval = 60*5 ) {
51+
self.batchSize = batchSize > 0 ? batchSize : 1
5352
self.backingStore = backingStore
5453
self.backingStoreName = dataStoreName
5554
self.timerInterval = timerInterval

OptimizelySDK/OptimizelyTests/OptimizelyTests-Common/EventDispatcherTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ class EventDispatcherTests: XCTestCase {
238238

239239
}
240240

241+
func testDispatcherZeroBatchSize() {
242+
let eventDispatcher = DefaultEventDispatcher(batchSize: 0, backingStore: .userDefaults, dataStoreName: "DoNothing", timerInterval: 0)
243+
244+
XCTAssert(eventDispatcher.batchSize > 0)
245+
}
246+
241247
func testDataStoreQueue() {
242248
let queue = DataStoreQueueStackImpl<EventForDispatch>(queueStackName: "OPTEventQueue", dataStore: DataStoreMemory<Array<Data>>(storeName: "backingStoreName"))
243249

0 commit comments

Comments
 (0)