mirror of
https://github.com/hanzo-fi/stack.git
synced 2026-10-30 20:34:43 +00:00
20 lines
431 B
Go
20 lines
431 B
Go
package nats
|
|
|
|
import (
|
|
"github.com/formancehq/operator/apis/stack/v1beta3"
|
|
"github.com/nats-io/nats.go"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func NewClient(natsConfig *v1beta3.NatsConfig, clientId string) (*nats.Conn, error) {
|
|
options := []nats.Option{
|
|
nats.Name(clientId),
|
|
}
|
|
conn, err := nats.Connect(natsConfig.URL, options...)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "cannot connect to nats-core")
|
|
}
|
|
|
|
return conn, nil
|
|
}
|