gofmt fixes
This commit is contained in:
@@ -38,9 +38,9 @@ func NewKafkaNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
|||||||
return nil, alerting.ValidationError{Reason: "Could not find kafka rest proxy endpoint property in settings"}
|
return nil, alerting.ValidationError{Reason: "Could not find kafka rest proxy endpoint property in settings"}
|
||||||
}
|
}
|
||||||
topic := model.Settings.Get("kafkaTopic").MustString()
|
topic := model.Settings.Get("kafkaTopic").MustString()
|
||||||
if topic == "" {
|
if topic == "" {
|
||||||
return nil, alerting.ValidationError{Reason: "Could not find kafka topic property in settings"}
|
return nil, alerting.ValidationError{Reason: "Could not find kafka topic property in settings"}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &KafkaNotifier{
|
return &KafkaNotifier{
|
||||||
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
NotifierBase: NewNotifierBase(model.Id, model.IsDefault, model.Name, model.Type, model.Settings),
|
||||||
@@ -52,9 +52,9 @@ func NewKafkaNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
|||||||
|
|
||||||
type KafkaNotifier struct {
|
type KafkaNotifier struct {
|
||||||
NotifierBase
|
NotifierBase
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Topic string
|
Topic string
|
||||||
log log.Logger
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
|
func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
@@ -99,16 +99,16 @@ func (this *KafkaNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
recordJSON.Set("records", records)
|
recordJSON.Set("records", records)
|
||||||
body, _ := recordJSON.MarshalJSON()
|
body, _ := recordJSON.MarshalJSON()
|
||||||
|
|
||||||
topicUrl := this.Endpoint+"/topics/"+this.Topic
|
topicUrl := this.Endpoint + "/topics/" + this.Topic
|
||||||
|
|
||||||
cmd := &m.SendWebhookSync{
|
cmd := &m.SendWebhookSync{
|
||||||
Url: topicUrl,
|
Url: topicUrl,
|
||||||
Body: string(body),
|
Body: string(body),
|
||||||
HttpMethod: "POST",
|
HttpMethod: "POST",
|
||||||
HttpHeader: map[string]string{
|
HttpHeader: map[string]string{
|
||||||
"Content-Type": "application/vnd.kafka.json.v2+json",
|
"Content-Type": "application/vnd.kafka.json.v2+json",
|
||||||
"Accept": "application/vnd.kafka.v2+json",
|
"Accept": "application/vnd.kafka.v2+json",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
|
if err := bus.DispatchCtx(evalContext.Ctx, cmd); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user