From 044f726ae40abbdd1f634ca8e473ffcb31e5fdc5 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 24 Mar 2021 13:09:07 -0700 Subject: [PATCH 1/2] Ammending Event Bus Api to remove Pointers --- event/eventQueue.go | 10 +++++----- event/eventmanager.go | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/event/eventQueue.go b/event/eventQueue.go index f65ec77..94b40eb 100644 --- a/event/eventQueue.go +++ b/event/eventQueue.go @@ -19,7 +19,7 @@ type simpleQueue struct { // the event.Manager. type Queue interface { Publish(event Event) - Next() *Event + Next() Event Shutdown() OutChan() <-chan Event Len() int @@ -52,9 +52,9 @@ func (sq *simpleQueue) Len() int { } // Next returns the next available event from the front of the queue -func (sq *simpleQueue) Next() *Event { +func (sq *simpleQueue) Next() Event { event := <-sq.eventChannel - return &event + return event } // Shutdown closes our eventChannel @@ -83,9 +83,9 @@ func (iq *queue) OutChan() <-chan Event { } // Out returns the next available event from the front of the queue -func (iq *queue) Next() *Event { +func (iq *queue) Next() Event { event := <-iq.infChan.Out() - return &event + return event } func (iq *queue) Len() int { diff --git a/event/eventmanager.go b/event/eventmanager.go index 3ce621e..8ab9165 100644 --- a/event/eventmanager.go +++ b/event/eventmanager.go @@ -7,7 +7,8 @@ import ( "sync" ) -// Event is a structure which binds a given set of data to an Type +// Events are the core struct passed around between various subsystems, they consist of a type which can be +// filtered on, an event ID for tracing and a map of Fields to string values. type Event struct { EventType Type EventID string -- 2.25.1 From 5881fd459c90f7c385613c58081b7dc57d36bc68 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 24 Mar 2021 13:16:50 -0700 Subject: [PATCH 2/2] Better event comments --- event/eventmanager.go | 2 +- storage/v1/profile_store.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/event/eventmanager.go b/event/eventmanager.go index 8ab9165..be1c19f 100644 --- a/event/eventmanager.go +++ b/event/eventmanager.go @@ -7,7 +7,7 @@ import ( "sync" ) -// Events are the core struct passed around between various subsystems, they consist of a type which can be +// Event is the core struct type passed around between various subsystems. Events consist of a type which can be // filtered on, an event ID for tracing and a map of Fields to string values. type Event struct { EventType Type diff --git a/storage/v1/profile_store.go b/storage/v1/profile_store.go index b26b485..4947773 100644 --- a/storage/v1/profile_store.go +++ b/storage/v1/profile_store.go @@ -383,7 +383,7 @@ func (ps *ProfileStoreV1) eventHandler() { log.Errorf("error storing new group invite: %v (%v)", err, ev) } case event.SendMessageToPeer: // cache the message till an ack, then it's given to stream store. - // stream store doesn't support updates, so we don't want to commit it till ack'd + // stream store doesn't support updates, so we don't want to commit it till ack'd ps.profile.AddSentMessageToContactTimeline(ev.Data[event.RemotePeer], ev.Data[event.Data], time.Now(), ev.EventID) case event.NewMessageFromPeer: ps.attemptSavePeerMessage(ev.Data[event.RemotePeer], ev.Data[event.Data], ev.Data[event.TimestampReceived], true) -- 2.25.1