Skip to content

Commit 60eeead

Browse files
fix: instantiate event processor with dispatcher (#239)
* fix: instantiate event processor with dispatcher
1 parent 6f7a8c9 commit 60eeead

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
- mkdir -p $GOPATH/src/github.com && pushd $GOPATH/src/github.com && ln -s $HOME/build/optimizely optimizely && popd
5454
script:
5555
# Need to download packages explicitly
56+
- mkdir $GOPATH/src/github.com/twmb && cd $GOPATH/src/github.com/twmb && git clone https://github.com/twmb/murmur3.git && cd $TRAVIS_BUILD_DIR
57+
- pushd $GOPATH/src/github.com/twmb/murmur3 && git checkout v1.0.0 && popd
5658
- go get -v -d ./...
5759
# This pkg not in go 1.8
5860
- go get github.com/stretchr/testify

pkg/event/processor.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,18 @@ func NewBatchEventProcessor(options ...BPOptionConfig) *BatchEventProcessor {
154154
p.Q = NewInMemoryQueue(p.MaxQueueSize)
155155
}
156156

157-
return p
158-
}
159-
160-
// Start initializes the event processor
161-
func (p *BatchEventProcessor) Start(ctx context.Context) {
162157
if p.EventDispatcher == nil {
163158
dispatcher := NewQueueEventDispatcher(p.metricsRegistry)
164-
defer dispatcher.flushEvents()
165159
p.EventDispatcher = dispatcher
166160
}
167161

168-
pLogger.Debug("Batch event processor started")
162+
return p
163+
}
164+
165+
// Start does not do any initialization, just starts the ticker
166+
func (p *BatchEventProcessor) Start(ctx context.Context) {
167+
168+
pLogger.Info("Batch event processor started")
169169
p.startTicker(ctx)
170170
}
171171

pkg/event/processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func newExecutionContext() *utils.ExecGroup {
6565
func TestDefaultEventProcessor_ProcessImpression(t *testing.T) {
6666
eg := newExecutionContext()
6767
processor := NewBatchEventProcessor()
68-
processor.EventDispatcher = nil
68+
processor.EventDispatcher = NewQueueEventDispatcher(processor.metricsRegistry)
6969
eg.Go(processor.Start)
7070

7171
impression := BuildTestImpressionEvent()

0 commit comments

Comments
 (0)