99
1010 "github.com/nats-io/nats.go"
1111 "github.com/nats-io/stan.go"
12- "github.com/netlify/netlify-commons/nconf"
1312 "github.com/pkg/errors"
1413 "github.com/sirupsen/logrus"
1514)
@@ -22,7 +21,7 @@ func init() {
2221 silent = logrus .NewEntry (l )
2322}
2423
25- func ConfigureNatsConnection (config * nconf. NatsConfig , log logrus.FieldLogger ) (* nats.Conn , error ) {
24+ func ConfigureNatsConnection (config * NatsConfig , log logrus.FieldLogger ) (* nats.Conn , error ) {
2625 if log == nil {
2726 log = silent
2827 }
@@ -49,7 +48,7 @@ func ConfigureNatsConnection(config *nconf.NatsConfig, log logrus.FieldLogger) (
4948 return nc , nil
5049}
5150
52- func ConnectToNats (config * nconf. NatsConfig , opts ... nats.Option ) (* nats.Conn , error ) {
51+ func ConnectToNats (config * NatsConfig , opts ... nats.Option ) (* nats.Conn , error ) {
5352 tlsConfig , err := config .TLS .TLSConfig ()
5453 if err != nil {
5554 return nil , errors .Wrap (err , "Failed to configure TLS" )
@@ -61,11 +60,11 @@ func ConnectToNats(config *nconf.NatsConfig, opts ...nats.Option) (*nats.Conn, e
6160 }
6261
6362 switch strings .ToLower (config .Auth .Method ) {
64- case nconf . NatsAuthMethodUser :
63+ case NatsAuthMethodUser :
6564 opts = append (opts , nats .UserInfo (config .Auth .User , config .Auth .Password ))
66- case nconf . NatsAuthMethodToken :
65+ case NatsAuthMethodToken :
6766 opts = append (opts , nats .Token (config .Auth .Token ))
68- case nconf . NatsAuthMethodTLS :
67+ case NatsAuthMethodTLS :
6968 // if using TLS auth, make sure the client certificate is loaded
7069 if tlsConfig == nil || len (tlsConfig .Certificates ) == 0 {
7170 return nil , fmt .Errorf ("TLS auth method is configured but no certificate was loaded" )
@@ -78,7 +77,7 @@ func ConnectToNats(config *nconf.NatsConfig, opts ...nats.Option) (*nats.Conn, e
7877 return nats .Connect (config .ServerString (), opts ... )
7978}
8079
81- func ConfigureNatsStreaming (config * nconf. NatsConfig , log logrus.FieldLogger ) (stan.Conn , error ) {
80+ func ConfigureNatsStreaming (config * NatsConfig , log logrus.FieldLogger ) (stan.Conn , error ) {
8281 // connect to the underlying instance
8382 nc , err := ConfigureNatsConnection (config , log )
8483 if err != nil {
@@ -93,7 +92,7 @@ func ConfigureNatsStreaming(config *nconf.NatsConfig, log logrus.FieldLogger) (s
9392 return conn , nil
9493}
9594
96- func ConnectToNatsStreaming (nc * nats.Conn , config * nconf. NatsConfig , log logrus.FieldLogger ) (stan.Conn , error ) {
95+ func ConnectToNatsStreaming (nc * nats.Conn , config * NatsConfig , log logrus.FieldLogger ) (stan.Conn , error ) {
9796 if config .ClusterID == "" {
9897 return nil , errors .New ("Must provide a cluster ID to connect to streaming nats" )
9998 }
0 commit comments