natsio/node.go

29 lines
742 B
Go
Raw Normal View History

2023-04-27 04:19:33 +00:00
package natsio
import (
"fmt"
"github.com/nats-io/nats.go"
)
// 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)
if _, err := n.Sv.QueueSubscribe(subjectName, queueName, h); err != nil {
fmt.Printf("[natsio.Node.ServerQueueSubscribe] error: %s \n", err.Error())
}
}
func (n Node) JetStreamQueueSubscribe(subjectName string, h nats.MsgHandler) {
queueName := GenerateQueueNameFromSubject(subjectName)
if err := n.Js.QueueSubscribe(subjectName, queueName, h); err != nil {
fmt.Printf("[natsio.Node.ServerQueueSubscribe] error: %s \n", err.Error())
}
}