2020-08-18 18:19:53 +03:00
|
|
|
package nats
|
|
|
|
|
2020-08-19 12:55:54 +03:00
|
|
|
import "crypto/tls"
|
|
|
|
|
2020-08-18 18:19:53 +03:00
|
|
|
// Options which are used to configure the nats stream
|
|
|
|
type Options struct {
|
|
|
|
ClusterID string
|
|
|
|
ClientID string
|
|
|
|
Address string
|
2020-08-19 12:55:54 +03:00
|
|
|
TLSConfig *tls.Config
|
2020-08-18 18:19:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
}
|
2020-08-19 12:55:54 +03:00
|
|
|
|
|
|
|
// TLSConfig to use when connecting to the cluster
|
|
|
|
func TLSConfig(t *tls.Config) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.TLSConfig = t
|
|
|
|
}
|
|
|
|
}
|