414ba6e0a2
Create and connect to an endpoint using separate functions. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
38 lines
699 B
Go
38 lines
699 B
Go
package nats
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/nats-io/nats.go"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func WithClientCert(certPath, keyPath string) Option {
|
|
return func(o *opts) {
|
|
o.nOpts = append(o.nOpts, nats.ClientCert(certPath, keyPath))
|
|
}
|
|
}
|
|
|
|
func WithRootCA(paths ...string) Option {
|
|
return func(o *opts) {
|
|
o.nOpts = append(o.nOpts, nats.RootCAs(paths...))
|
|
}
|
|
}
|
|
|
|
func WithTimeout(timeout time.Duration) Option {
|
|
return func(o *opts) {
|
|
o.nOpts = append(o.nOpts, nats.Timeout(timeout))
|
|
}
|
|
}
|
|
|
|
func WithConnectionName(name string) Option {
|
|
return func(o *opts) {
|
|
o.nOpts = append(o.nOpts, nats.Name(name))
|
|
}
|
|
}
|
|
|
|
func WithLogger(logger *zap.Logger) Option {
|
|
return func(o *opts) {
|
|
o.log = logger
|
|
}
|
|
}
|