From 3f3281ed0da0b84f18037ed01ed57c2aee787538 Mon Sep 17 00:00:00 2001 From: Thomas Zurkan Date: Thu, 7 Nov 2019 19:18:37 -0800 Subject: [PATCH 1/2] update for semaphore --- go.mod | 1 + go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/go.mod b/go.mod index ff0893964..9ef37e039 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/spf13/cobra v0.0.5 github.com/stretchr/testify v1.4.0 github.com/twmb/murmur3 v1.0.0 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e ) // Work around issue wtih git.apache.org/thrift.git diff --git a/go.sum b/go.sum index d013e9d07..d0ec11357 100644 --- a/go.sum +++ b/go.sum @@ -48,6 +48,8 @@ github.com/twmb/murmur3 v1.0.0/go.mod h1:5Y5m8Y8WIyucaICVP+Aep5C8ydggjEuRQHDq1ic github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 66d1511d52e4890c823c90204e206963fc0ba91e Mon Sep 17 00:00:00 2001 From: Thomas Zurkan Date: Thu, 7 Nov 2019 19:44:55 -0800 Subject: [PATCH 2/2] cleanup processor tests --- pkg/event/processor_test.go | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/pkg/event/processor_test.go b/pkg/event/processor_test.go index 6f99d19a8..202586fb7 100644 --- a/pkg/event/processor_test.go +++ b/pkg/event/processor_test.go @@ -67,7 +67,10 @@ func TestDefaultEventProcessor_ProcessImpression(t *testing.T) { func TestCustomEventProcessor_Create(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithEventDispatcher(NewMockDispatcher(100, false)), WithQueueSize(10), WithFlushInterval(100)) + processor := NewBatchEventProcessor( + WithEventDispatcher(NewMockDispatcher(100, false)), + WithQueueSize(10), + WithFlushInterval(100)) processor.Start(exeCtx) impression := BuildTestImpressionEvent() @@ -85,8 +88,10 @@ func TestCustomEventProcessor_Create(t *testing.T) { func TestDefaultEventProcessor_LogEventNotification(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithFlushInterval(100), WithQueueSize(100), - WithQueue(NewInMemoryQueue(100)), WithEventDispatcher(NewMockDispatcher(100, false)), + processor := NewBatchEventProcessor( + WithQueueSize(100), + WithQueue(NewInMemoryQueue(100)), + WithEventDispatcher(NewMockDispatcher(100, false)), WithSDKKey("fakeSDKKey")) var logEvent LogEvent @@ -118,7 +123,8 @@ func TestDefaultEventProcessor_LogEventNotification(t *testing.T) { func TestDefaultEventProcessor_DefaultConfig(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithEventDispatcher(NewMockDispatcher(100, false))) + processor := NewBatchEventProcessor( + WithEventDispatcher(NewMockDispatcher(100, false))) processor.Start(exeCtx) impression := BuildTestImpressionEvent() @@ -321,8 +327,10 @@ func TestBatchEventProcessor_FlushesOnClose(t *testing.T) { func TestDefaultEventProcessor_ProcessBatchRevisionMismatch(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithQueueSize(100), WithFlushInterval(100), - WithQueue(NewInMemoryQueue(100)), WithEventDispatcher(NewMockDispatcher(100, false))) + processor := NewBatchEventProcessor( + WithQueueSize(100), + WithQueue(NewInMemoryQueue(100)), + WithEventDispatcher(NewMockDispatcher(100, false))) processor.Start(exeCtx) @@ -355,8 +363,10 @@ func TestDefaultEventProcessor_ProcessBatchRevisionMismatch(t *testing.T) { func TestDefaultEventProcessor_ProcessBatchProjectMismatch(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithQueueSize(100), WithFlushInterval(100), - WithQueue(NewInMemoryQueue(100)), WithEventDispatcher(NewMockDispatcher(100, false))) + processor := NewBatchEventProcessor( + WithQueueSize(100), + WithQueue(NewInMemoryQueue(100)), + WithEventDispatcher(NewMockDispatcher(100, false))) processor.Start(exeCtx) @@ -389,8 +399,10 @@ func TestDefaultEventProcessor_ProcessBatchProjectMismatch(t *testing.T) { func TestChanQueueEventProcessor_ProcessImpression(t *testing.T) { exeCtx := utils.NewCancelableExecutionCtx() - processor := NewBatchEventProcessor(WithQueueSize(100), WithFlushInterval(100), - WithQueue(NewInMemoryQueue(100)), WithEventDispatcher(&HTTPEventDispatcher{})) + processor := NewBatchEventProcessor( + WithQueueSize(100), + WithQueue(NewInMemoryQueue(100)), + WithEventDispatcher(&HTTPEventDispatcher{})) processor.Start(exeCtx)