micro/events/nats/options.go
ben-toogood 66df1bb361
events/nats: add support for TLS config (#1946)
* events/nats: add support for TLS config

* events/nats: improve error logging
2020-08-19 10:55:54 +01:00

43 lines
813 B
Go

package nats
import "crypto/tls"
// Options which are used to configure the nats stream
type Options struct {
ClusterID string
ClientID string
Address string
TLSConfig *tls.Config
}
// Option is a function which configures options
type Option func(o *Options)
// ClusterID sets the cluster id for the nats connection
func ClusterID(id string) Option {
return func(o *Options) {
o.ClusterID = id
}
}
// ClientID sets the client id for the nats connection
func ClientID(id string) Option {
return func(o *Options) {
o.ClientID = id
}
}
// Address of the nats cluster
func Address(addr string) Option {
return func(o *Options) {
o.Address = addr
}
}
// TLSConfig to use when connecting to the cluster
func TLSConfig(t *tls.Config) Option {
return func(o *Options) {
o.TLSConfig = t
}
}