forked from linkedin/Iris-message-processor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dummyVendor.go
38 lines (30 loc) · 1.11 KB
/
dummyVendor.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
package main
import (
gometrics "github.com/rcrowley/go-metrics"
uuid "github.com/satori/go.uuid"
)
type DummyVendor struct {
*Vendor
}
// NewDummyVendor create new DummyVendor instance
func NewDummyVendor(dbClient *DbClient, config *Config, logger *Logger, metricsRegistry *gometrics.Registry) *DummyVendor {
vendor := NewVendor(dbClient, config, logger, "dummyVendor")
dummyVendor := DummyVendor{Vendor: vendor}
if appConfig.MetricsDryRun == false && metricsRegistry != nil {
dummyVendor.Vendor.RegisterMetrics(*metricsRegistry)
}
return &dummyVendor
}
func (d *DummyVendor) SendMessage(message MessageQueueItem) bool {
// check if message is part of aggregated batch
if message.batchID == uuid.Nil {
if d.config.StorageDryRun {
d.logger.Infof("DummyVendor SendMessage: %s, %s, %s ", message.message.Target, message.message.Mode, message.message.Destination)
}
d.Vendor.persistMsg(message, "", "DummyVendor pretended to send this message (dropped)")
} else {
d.Vendor.persistMsg(message, "", "message part of aggregated batch: "+message.batchID.String())
}
d.Vendor.counterSuccesses.Inc(1)
return true
}