Files
QSfera/Server/services/nats/pkg/server/nats/options.go
T
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

53 lines
1.1 KiB
Go

package nats
import (
"crypto/tls"
nserver "github.com/nats-io/nats-server/v2/server"
)
// NatsOption configures the nats server
type NatsOption func(*nserver.Options)
// Host sets the host URL for the nats server
func Host(url string) NatsOption {
return func(o *nserver.Options) {
o.Host = url
}
}
// Port sets the host URL for the nats server
func Port(port int) NatsOption {
return func(o *nserver.Options) {
o.Port = port
}
}
// ClusterID sets the name for the nats cluster
func ClusterID(clusterID string) NatsOption {
return func(o *nserver.Options) {
o.Cluster.Name = clusterID
}
}
// StoreDir sets the folder for persistence
func StoreDir(StoreDir string) NatsOption {
return func(o *nserver.Options) {
o.StoreDir = StoreDir
}
}
// TLSConfig sets the tls config for the nats server
func TLSConfig(c *tls.Config) NatsOption {
return func(o *nserver.Options) {
o.TLSConfig = c
}
}
// AllowNonTLS sets the allow non tls options for the nats server
func AllowNonTLS(v bool) NatsOption {
return func(o *nserver.Options) {
o.AllowNonTLS = v
}
}