Add helpful comments

This commit is contained in:
Anant Prakash 2018-08-08 19:04:28 +05:30
parent 3d6a862433
commit 1de4050962
No known key found for this signature in database
GPG key ID: C5D399F626523045
4 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -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"`
}