@@ -40,6 +40,7 @@ import (
40
40
type EventClientConfig struct {
41
41
DestinationURL string `env:"EVENT_URL" envDefault:"http://localhost:3000/notify" description:"Notifier service url"`
42
42
NotificationMedium NotificationMedium `env:"NOTIFICATION_MEDIUM" envDefault:"rest" description:"notification medium"`
43
+ EnableNotifierV2 bool `env:"ENABLE_NOTIFIER_V2" envDefault:"false" description:"enable notifier v2"`
43
44
}
44
45
type NotificationMedium string
45
46
@@ -259,21 +260,34 @@ func (impl *EventRESTClientImpl) sendEventsOnNats(body []byte) error {
259
260
// do not call this method if notification module is not installed
260
261
func (impl * EventRESTClientImpl ) sendEvent (event Event ) (bool , error ) {
261
262
impl .logger .Debugw ("event before send" , "event" , event )
262
- body , err := json .Marshal (event )
263
- if err != nil {
264
- impl .logger .Errorw ("error while marshaling event request " , "err" , err )
265
- return false , err
266
- }
267
- if impl .config .NotificationMedium == PUB_SUB {
268
- err = impl .sendEventsOnNats (body )
263
+ var body string
264
+ var destinationUrl string
265
+ if impl .config .EnableNotifierV2 {
266
+ // logic to get NotificationSettings from event
267
+
268
+ // embed event and NotificationSettings in body
269
+
270
+ // destination Url
271
+ destinationUrl = impl .config .DestinationURL + "/v2"
272
+ } else {
273
+ destinationUrl = impl .config .DestinationURL
274
+ body , err := json .Marshal (event )
269
275
if err != nil {
270
- impl .logger .Errorw ("error while publishing event " , "err" , err )
276
+ impl .logger .Errorw ("error while marshaling event request " , "err" , err )
271
277
return false , err
272
278
}
273
- return true , nil
279
+ if impl .config .NotificationMedium == PUB_SUB {
280
+ err = impl .sendEventsOnNats (body )
281
+ if err != nil {
282
+ impl .logger .Errorw ("error while publishing event " , "err" , err )
283
+ return false , err
284
+ }
285
+ return true , nil
286
+ }
274
287
}
288
+
275
289
var reqBody = []byte (body )
276
- req , err := http .NewRequest (http .MethodPost , impl . config . DestinationURL , bytes .NewBuffer (reqBody ))
290
+ req , err := http .NewRequest (http .MethodPost , destinationUrl , bytes .NewBuffer (reqBody ))
277
291
if err != nil {
278
292
impl .logger .Errorw ("error while writing event" , "err" , err )
279
293
return false , err
0 commit comments