mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Summarise key change logs (#1278)
This commit is contained in:
parent
02a8515e99
commit
e571e196ce
1 changed files with 6 additions and 5 deletions
|
@ -42,6 +42,7 @@ func (p *KeyChange) DefaultPartition() int32 {
|
||||||
|
|
||||||
// ProduceKeyChanges creates new change events for each key
|
// ProduceKeyChanges creates new change events for each key
|
||||||
func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceMessage) error {
|
func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceMessage) error {
|
||||||
|
userToDeviceCount := make(map[string]int)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
var m sarama.ProducerMessage
|
var m sarama.ProducerMessage
|
||||||
|
|
||||||
|
@ -62,12 +63,12 @@ func (p *KeyChange) ProduceKeyChanges(keys []api.DeviceMessage) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
userToDeviceCount[key.UserID]++
|
||||||
|
}
|
||||||
|
for userID, count := range userToDeviceCount {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"user_id": key.UserID,
|
"user_id": userID,
|
||||||
"device_id": key.DeviceID,
|
"num_key_changes": count,
|
||||||
"partition": partition,
|
|
||||||
"offset": offset,
|
|
||||||
"len_key_bytes": len(key.KeyJSON),
|
|
||||||
}).Infof("Produced to key change topic '%s'", p.Topic)
|
}).Infof("Produced to key change topic '%s'", p.Topic)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue