This repository has no description
1package notella
2
3import (
4 "encoding/json"
5 "fmt"
6
7 ll "github.com/gwennlbh/label-logger-go"
8 "github.com/nats-io/nats.go/jetstream"
9)
10
11const StreamName = "notella:stream"
12const SubjectName = "notella:notification"
13const ConsumerName = "NotellaConsumer"
14
15func NatsReceiver(m jetstream.Msg) error {
16 var message Message
17 err := json.Unmarshal(m.Data(), &message)
18 if err != nil {
19 return fmt.Errorf("while unmarshaling received message: %w", err)
20 }
21
22 if message.Event != EventShowScheduledJobs {
23 ll.Log("Received", "cyan", message.String())
24 }
25
26 if len(message.ClearScheduleFor) > 0 {
27 UnscheduleAllForObject(message.ChurrosObjectId, message.ClearScheduleFor...)
28 }
29
30 message.Schedule()
31
32 return nil
33}