From 1de4050962bebee0ccd5aff7268b1f1e1c53dc00 Mon Sep 17 00:00:00 2001 From: Anant Prakash Date: Wed, 8 Aug 2018 19:04:28 +0530 Subject: [PATCH] Add helpful comments --- .../dendrite/federationsender/consumers/typingserver.go | 2 ++ .../dendrite/federationsender/queue/destinationqueue.go | 4 ++-- .../matrix-org/dendrite/federationsender/queue/queue.go | 6 +++--- .../matrix-org/dendrite/typingserver/api/output.go | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/federationsender/consumers/typingserver.go b/src/github.com/matrix-org/dendrite/federationsender/consumers/typingserver.go index ddc926f0d..0cf9ea50d 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/consumers/typingserver.go +++ b/src/github.com/matrix-org/dendrite/federationsender/consumers/typingserver.go @@ -62,6 +62,8 @@ func (t *OutputTypingEventConsumer) Start() error { return t.consumer.Start() } +// onMessage is called for OutputTypingEvent recieved from the typing servers. +// Parses the msg, creates a matrix federation EDU and sends it to joined hosts. func (t *OutputTypingEventConsumer) onMessage(msg *sarama.ConsumerMessage) error { // Extract the typing event from msg. var ote api.OutputTypingEvent diff --git a/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go b/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go index 026e3e51c..64d721d4a 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go +++ b/src/github.com/matrix-org/dendrite/federationsender/queue/destinationqueue.go @@ -58,10 +58,10 @@ func (oq *destinationQueue) sendEvent(ev *gomatrixserverlib.Event) { // sendEDU adds the EDU event to the pending queue for the destination. // If the queue is empty then it starts a background goroutine to // start sending event to that destination. -func (oq *destinationQueue) sendEDU(ev *gomatrixserverlib.EDU) { +func (oq *destinationQueue) sendEDU(e *gomatrixserverlib.EDU) { oq.runningMutex.Lock() defer oq.runningMutex.Unlock() - oq.pendingEDUs = append(oq.pendingEDUs, ev) + oq.pendingEDUs = append(oq.pendingEDUs, e) if !oq.running { oq.running = true go oq.backgroundSend() diff --git a/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go b/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go index 8d910f627..4a38dc086 100644 --- a/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go +++ b/src/github.com/matrix-org/dendrite/federationsender/queue/queue.go @@ -82,7 +82,7 @@ func (oqs *OutgoingQueues) SendEvent( // SendEDU sends an EDU event to the destinations func (oqs *OutgoingQueues) SendEDU( - ev *gomatrixserverlib.EDU, origin gomatrixserverlib.ServerName, + e *gomatrixserverlib.EDU, origin gomatrixserverlib.ServerName, destinations []gomatrixserverlib.ServerName, ) error { if origin != oqs.origin { @@ -97,7 +97,7 @@ func (oqs *OutgoingQueues) SendEDU( destinations = filterDestinations(oqs.origin, destinations) log.WithFields(log.Fields{ - "destinations": destinations, "edu_type": ev.Type, + "destinations": destinations, "edu_type": e.Type, }).Info("Sending EDU event") oqs.queuesMutex.Lock() @@ -113,7 +113,7 @@ func (oqs *OutgoingQueues) SendEDU( oqs.queues[destination] = oq } - oq.sendEDU(ev) + oq.sendEDU(e) } return nil diff --git a/src/github.com/matrix-org/dendrite/typingserver/api/output.go b/src/github.com/matrix-org/dendrite/typingserver/api/output.go index 39b4b7d1e..813b9b7c7 100644 --- a/src/github.com/matrix-org/dendrite/typingserver/api/output.go +++ b/src/github.com/matrix-org/dendrite/typingserver/api/output.go @@ -13,10 +13,12 @@ package api // OutputTypingEvent is an entry in typing server output kafka log. +// This contains the event with extra fields used to create 'm.typing' event +// in clientapi & federation. type OutputTypingEvent struct { // The Event for the typing edu event. Event TypingEvent `json:"event"` - // Users typing in the room at the event. + // Users typing in the room when the event was generated. TypingUsers []string `json:"typing_users"` }