add logs for node

This commit is contained in:
Nam Huynh 2023-01-04 14:02:10 +07:00
parent aa90517c12
commit 7efc654cfd
1 changed files with 12 additions and 3 deletions

15
node.go
View File

@ -1,6 +1,10 @@
package natsio
import "github.com/nats-io/nats.go"
import (
"fmt"
"github.com/nats-io/nats.go"
)
// Node include all necessary things of a client
type Node struct {
@ -10,10 +14,15 @@ type Node struct {
func (n Node) ServerQueueSubscribe(subjectName string, h nats.MsgHandler) {
queueName := GenerateQueueNameFromSubject(subjectName)
_, _ = n.Sv.QueueSubscribe(subjectName, queueName, h)
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)
_ = n.Js.QueueSubscribe(subjectName, queueName, h)
if err := n.Js.QueueSubscribe(subjectName, queueName, h); err != nil {
fmt.Printf("[natsio.Node.ServerQueueSubscribe] error: %s \n", err.Error())
}
}