From 415039292b351fcb9f52058deec5c86228f8c49a Mon Sep 17 00:00:00 2001 From: namhq1989 Date: Wed, 28 Dec 2022 22:11:56 +0700 Subject: [PATCH] add node --- node.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 node.go diff --git a/node.go b/node.go new file mode 100644 index 0000000..4c6ec8b --- /dev/null +++ b/node.go @@ -0,0 +1,19 @@ +package natsio + +import "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) + _, _ = n.Sv.QueueSubscribe(subjectName, queueName, h) +} + +func (n Node) JetStreamQueueSubscribe(subjectName string, h nats.MsgHandler) { + queueName := GenerateQueueNameFromSubject(subjectName) + _ = n.Js.QueueSubscribe(subjectName, queueName, h) +}