fix: add basic JetStream management; bump: nats.go v1.12.3 (BREAKING to use with nack)

This commit is contained in:
jar3b
2021-09-29 14:37:13 +03:00
parent 5cf7a062b9
commit 1e18f34ee2
4 changed files with 122 additions and 52 deletions

19
nacl.go
View File

@@ -12,7 +12,6 @@ import (
var (
NatsClient *nats.Conn
StanClient stan.Conn
JsClient nats.JetStreamContext
natsLock = sync.Mutex{}
stanLock = sync.Mutex{}
)
@@ -41,20 +40,6 @@ func SetupNatsWithCreds(host string, port int, credsFile string, closeHandler *g
return nil
}
func SetupJetStream(host string, port int, credsFile string, closeHandler *grawt.CloseHandler, opts ...nats.JSOpt) error {
var err error
if err := SetupNatsWithCreds(host, port, credsFile, closeHandler); err != nil {
return err
}
JsClient, err = NatsClient.JetStream(opts...)
if err != nil {
return fmt.Errorf("Cannot init JS: %v", err)
}
return nil
}
func SetupNats(host string, port int, user string, pass string, closeHandler *grawt.CloseHandler) error {
natsLock.Lock()
defer natsLock.Unlock()
@@ -143,7 +128,3 @@ func FinalizeNats(subscriptions *[]*nats.Subscription) error {
return nil
}
func FinalizeJetStream(subscriptions *[]*nats.Subscription) error {
return FinalizeNats(subscriptions)
}