11/****************************************************************************
2- * Copyright 2019, Optimizely, Inc. and contributors *
2+ * Copyright 2019-2020 , Optimizely, Inc. and contributors *
33 * *
44 * Licensed under the Apache License, Version 2.0 (the "License"); *
55 * you may not use this file except in compliance with the License. *
@@ -46,6 +46,7 @@ type BatchEventProcessor struct {
4646 MaxQueueSize int // max size of the queue before flush
4747 FlushInterval time.Duration // in milliseconds
4848 BatchSize int
49+ EventEndPoint string
4950 Q Queue
5051 flushLock sync.Mutex
5152 Ticker * time.Ticker
@@ -64,6 +65,9 @@ const DefaultEventQueueSize = 2000
6465// DefaultEventFlushInterval holds the default value for the event flush interval
6566const DefaultEventFlushInterval = 30 * time .Second
6667
68+ // DefaultEventEndPoint is used as the default endpoint for sending events.
69+ const DefaultEventEndPoint = "https://logx.optimizely.com/v1/events"
70+
6771const maxFlushWorkers = 1
6872
6973// BPOptionConfig is the BatchProcessor options that give you the ability to add one more more options before the processor is initialized.
@@ -76,6 +80,13 @@ func WithBatchSize(bsize int) BPOptionConfig {
7680 }
7781}
7882
83+ // WithEventEndPoint sets the end point as a config option to be passed into the NewProcessor method
84+ func WithEventEndPoint (endPoint string ) BPOptionConfig {
85+ return func (qp * BatchEventProcessor ) {
86+ qp .EventEndPoint = endPoint
87+ }
88+ }
89+
7990// WithQueueSize sets the queue size as a config option to be passed into the NewProcessor method
8091func WithQueueSize (qsize int ) BPOptionConfig {
8192 return func (qp * BatchEventProcessor ) {
@@ -141,6 +152,10 @@ func NewBatchEventProcessor(options ...BPOptionConfig) *BatchEventProcessor {
141152 p .BatchSize = DefaultBatchSize
142153 }
143154
155+ if p .EventEndPoint == "" {
156+ p .EventEndPoint = DefaultEventEndPoint
157+ }
158+
144159 if p .BatchSize > p .MaxQueueSize {
145160 p .logger .Warning (
146161 fmt .Sprintf ("Batch size %d is larger than queue size %d. Setting to defaults" ,
@@ -297,7 +312,7 @@ func (p *BatchEventProcessor) flushEvents() {
297312 }
298313 if batchEventCount > 0 {
299314 // TODO: figure out what to do with the error
300- logEvent := createLogEvent (batchEvent )
315+ logEvent := createLogEvent (batchEvent , p . EventEndPoint )
301316 notificationCenter := registry .GetNotificationCenter (p .sdkKey )
302317
303318 err := notificationCenter .Send (notification .LogEvent , logEvent )
0 commit comments