mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 03:13:11 -06:00
Add helpful comments
This commit is contained in:
parent
3d6a862433
commit
1de4050962
|
|
@ -62,6 +62,8 @@ func (t *OutputTypingEventConsumer) Start() error {
|
||||||
return t.consumer.Start()
|
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 {
|
func (t *OutputTypingEventConsumer) onMessage(msg *sarama.ConsumerMessage) error {
|
||||||
// Extract the typing event from msg.
|
// Extract the typing event from msg.
|
||||||
var ote api.OutputTypingEvent
|
var ote api.OutputTypingEvent
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ func (oq *destinationQueue) sendEvent(ev *gomatrixserverlib.Event) {
|
||||||
// sendEDU adds the EDU event to the pending queue for the destination.
|
// sendEDU adds the EDU event to the pending queue for the destination.
|
||||||
// If the queue is empty then it starts a background goroutine to
|
// If the queue is empty then it starts a background goroutine to
|
||||||
// start sending event to that destination.
|
// start sending event to that destination.
|
||||||
func (oq *destinationQueue) sendEDU(ev *gomatrixserverlib.EDU) {
|
func (oq *destinationQueue) sendEDU(e *gomatrixserverlib.EDU) {
|
||||||
oq.runningMutex.Lock()
|
oq.runningMutex.Lock()
|
||||||
defer oq.runningMutex.Unlock()
|
defer oq.runningMutex.Unlock()
|
||||||
oq.pendingEDUs = append(oq.pendingEDUs, ev)
|
oq.pendingEDUs = append(oq.pendingEDUs, e)
|
||||||
if !oq.running {
|
if !oq.running {
|
||||||
oq.running = true
|
oq.running = true
|
||||||
go oq.backgroundSend()
|
go oq.backgroundSend()
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ func (oqs *OutgoingQueues) SendEvent(
|
||||||
|
|
||||||
// SendEDU sends an EDU event to the destinations
|
// SendEDU sends an EDU event to the destinations
|
||||||
func (oqs *OutgoingQueues) SendEDU(
|
func (oqs *OutgoingQueues) SendEDU(
|
||||||
ev *gomatrixserverlib.EDU, origin gomatrixserverlib.ServerName,
|
e *gomatrixserverlib.EDU, origin gomatrixserverlib.ServerName,
|
||||||
destinations []gomatrixserverlib.ServerName,
|
destinations []gomatrixserverlib.ServerName,
|
||||||
) error {
|
) error {
|
||||||
if origin != oqs.origin {
|
if origin != oqs.origin {
|
||||||
|
|
@ -97,7 +97,7 @@ func (oqs *OutgoingQueues) SendEDU(
|
||||||
destinations = filterDestinations(oqs.origin, destinations)
|
destinations = filterDestinations(oqs.origin, destinations)
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"destinations": destinations, "edu_type": ev.Type,
|
"destinations": destinations, "edu_type": e.Type,
|
||||||
}).Info("Sending EDU event")
|
}).Info("Sending EDU event")
|
||||||
|
|
||||||
oqs.queuesMutex.Lock()
|
oqs.queuesMutex.Lock()
|
||||||
|
|
@ -113,7 +113,7 @@ func (oqs *OutgoingQueues) SendEDU(
|
||||||
oqs.queues[destination] = oq
|
oqs.queues[destination] = oq
|
||||||
}
|
}
|
||||||
|
|
||||||
oq.sendEDU(ev)
|
oq.sendEDU(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,12 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
// OutputTypingEvent is an entry in typing server output kafka log.
|
// 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 {
|
type OutputTypingEvent struct {
|
||||||
// The Event for the typing edu event.
|
// The Event for the typing edu event.
|
||||||
Event TypingEvent `json:"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"`
|
TypingUsers []string `json:"typing_users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue