29 lines
742 B
Go
29 lines
742 B
Go
|
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())
|
||
|
}
|
||
|
}
|