forked from linkedin/Iris-message-processor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dropVendor.go
42 lines (34 loc) · 1.16 KB
/
dropVendor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
gometrics "github.com/rcrowley/go-metrics"
uuid "github.com/satori/go.uuid"
)
type DropVendor struct {
*Vendor
}
// NewDropVendor create new DropVendor instance
func NewDropVendor(dbClient *DbClient, config *Config, logger *Logger, metricsRegistry *gometrics.Registry) *DropVendor {
vendor := NewVendor(dbClient, config, logger, "drop")
dropVendor := DropVendor{Vendor: vendor}
if appConfig.MetricsDryRun == false && metricsRegistry != nil {
dropVendor.Vendor.RegisterMetrics(*metricsRegistry)
}
return &dropVendor
}
func (d *DropVendor) SendMessage(message MessageQueueItem) bool {
// check if message is part of aggregated batch
if message.batchID == uuid.Nil {
if d.config.StorageDryRun {
d.logger.Infof("DropVendor dropped message: %s, %s, %s ", message.message.Target, message.message.Mode, message.message.Destination)
}
if d.config.PersistDroppedMsgs {
d.Vendor.persistMsg(message, "", "message dropped by user preference")
}
} else {
if d.config.PersistDroppedMsgs {
d.Vendor.persistMsg(message, "", "message part of aggregated batch: "+message.batchID.String())
}
}
d.Vendor.counterSuccesses.Inc(1)
return true
}