Add pull subscribe #1

Merged
namhq1989 merged 12 commits from add-pull-subscribe into master 2022-03-18 04:28:50 +00:00
2 changed files with 12 additions and 1 deletions
Showing only changes of commit f831591266 - Show all commits

View File

@ -55,7 +55,7 @@ func (js JetStream) PullSubscribe(stream, subject, durable, consumer string) (*n
info, err := js.instance.AddConsumer(stream, &nats.ConsumerConfig{
Durable: durable,
AckPolicy: nats.AckExplicitPolicy,
FilterSubject: channel,
FilterSubject: subject,
})
if err == nil {
fmt.Println("CONSUMER INFO", info)

View File

@ -21,6 +21,9 @@ type JetStream struct {
var (
natsServer Server
natsJetStream JetStream
// FIXME: delete this
jsPublic nats.JetStreamContext
)
// Connect ...
@ -62,6 +65,9 @@ func Connect(cfg Config) error {
}
natsJetStream.instance = js
// FIXME: delete this
jsPublic = js
return nil
}
@ -74,3 +80,8 @@ func GetServer() Server {
func GetJetStream() JetStream {
return natsJetStream
}
// GetJSPublic ...
func GetJSPublic() nats.JetStreamContext {
return jsPublic
}