natsio/node.go

29 lines
742 B
Go
Raw Permalink Normal View History

2022-12-28 15:11:56 +00:00
package natsio
2023-01-04 07:02:10 +00:00
import (
"fmt"
"github.com/nats-io/nats.go"
)
2022-12-28 15:11:56 +00:00
// Node include all necessary things of a client
type Node struct {
Sv Server
Js JetStream
}
func (n Node) ServerQueueSubscribe(subjectName string, h nats.MsgHandler) {
queueName := GenerateQueueNameFromSubject(subjectName)
2023-01-04 07:02:10 +00:00
if _, err := n.Sv.QueueSubscribe(subjectName, queueName, h); err != nil {
fmt.Printf("[natsio.Node.ServerQueueSubscribe] error: %s \n", err.Error())
}
2022-12-28 15:11:56 +00:00
}
func (n Node) JetStreamQueueSubscribe(subjectName string, h nats.MsgHandler) {
queueName := GenerateQueueNameFromSubject(subjectName)
2023-01-04 07:02:10 +00:00
if err := n.Js.QueueSubscribe(subjectName, queueName, h); err != nil {
fmt.Printf("[natsio.Node.ServerQueueSubscribe] error: %s \n", err.Error())
}
2022-12-28 15:11:56 +00:00
}