Skip to content

Commit

Permalink
Create a helper for jsm options from a context
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <rip@devco.net>
  • Loading branch information
ripienaar committed Feb 13, 2025
1 parent 3173c77 commit 76caa9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions natscontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"sort"
"strings"

"github.com/nats-io/jsm.go"
"github.com/nats-io/nats-server/v2/server/certstore"
"github.com/nats-io/nats.go"
"github.com/nats-io/nkeys"
Expand Down Expand Up @@ -324,6 +325,17 @@ func (c *Context) Connect(opts ...nats.Option) (*nats.Conn, error) {
return nats.Connect(c.ServerURL(), nopts...)
}

// JSMOptions creates options for the jsm manager
func (c *Context) JSMOptions(opts ...jsm.Option) ([]jsm.Option, error) {
jsmopts := []jsm.Option{
jsm.WithAPIPrefix(c.JSAPIPrefix()),
jsm.WithEventPrefix(c.JSEventPrefix()),
jsm.WithDomain(c.JSDomain()),
}

return append(jsmopts, opts...), nil
}

// NATSOptions creates NATS client configuration based on the contents of the context
func (c *Context) NATSOptions(opts ...nats.Option) ([]nats.Option, error) {
var nopts []nats.Option
Expand Down

0 comments on commit 76caa9a

Please sign in to comment.