Documentation ¶
Index ¶
Constants ¶
const ( DEFAULT_SERVER_PORT = natsserver.DEFAULT_PORT DEFAULT_CLUSTER_PORT = natsserver.DEFAULT_PORT + 1000 DEFAULT_MONITOR_PORT = natsserver.DEFAULT_HTTP_PORT DEFAULT_MAXPAYLOAD = 1024 * 100 // 100 KB DEFAULT_PROMETHEUS_EXPORTER_HTTP_PORT = 4444 )
Default config settings
Variables ¶
This section is empty.
Functions ¶
func NewNATSLogger ¶
func NewNATSLogger(logger *zerolog.Logger) natsserver.Logger
NewNATSLogger creates a new NATS logger that delegates to the provided logger
Types ¶
type NATSLogLevel ¶
type NATSLogLevel int
NATSLogLevel enum for log level setting
const ( NOLOG NATSLogLevel = iota DEBUG TRACE )
NATSLogLevel enum values
type NATSServer ¶
type NATSServer interface { Cluster() messaging.ClusterName // Addr will return the net.Addr object for the current listener. Addr() net.Addr // ClusterAddr returns the net.Addr object for the route listener. ClusterAddr() *net.TCPAddr // MonitorAddr will return the net.Addr object for the monitoring listener. MonitorAddr() *net.TCPAddr // PrometheusHTTPExportPort returns the HTTP port that the prometheus metrics are exported on PrometheusHTTPExportPort() int // NumClients will report the number of registered clients. NumClients() int // NumRemotes will report number of registered remotes. NumRemotes() int // NumRoutes will report the number of registered routes. NumRoutes() int // NumSubscriptions will report how many subscriptions are active. NumSubscriptions() uint32 // Start up the server, this will block. Start via a Go routine if needed. Start() // StartMonitoring starts the HTTP server if needed. StartMonitoring() error // Shutdown will shutdown the server instance by kicking out the AcceptLoop and closing all associated clients. Shutdown() // ReadyForConnections returns `true` if the server is ready to accept client and, if routing is enabled, route connections. // If after the duration `dur` the server is still not ready, returns `false`. ReadyForConnections(dur time.Duration) bool }
NATSServer is the Service interface for a NATS server
func NewNATSServer ¶
func NewNATSServer(config *NATSServerConfig) (NATSServer, error)
NewNATSServer creates a new NATSServer
type NATSServerConfig ¶
type NATSServerConfig struct { Cluster messaging.ClusterName // OPTIONAL ServerHost string // OPTIONAL - DEFAULT_SERVER_PORT ServerPort int // OPTIONAL MonitorHost string // OPTIONAL - DEFAULT_MONITOR_PORT MonitorPort int // OPTIONAL ClusterHost string // OPTIONAL - DEFAULT_CLUSTER_PORT ClusterPort int // OPTIONAL - if not specified, then it adds itself as a route - assuming that this is a cluster seed node. // However, this should normally be set to point to seed nodes. Routes []string // applies to ServerPort, i.e., client-server connections TLSConfig *tls.Config // applies to ClusterPort, i.e., server-server connections within the NATS cluster ClusterTLSConfig *tls.Config // Configures NATS server logging LogLevel NATSLogLevel // OPTIONAL MaxPayload int // OPTIONAL MaxConn int // OPTIONAL - Prometheus metrics exporter HTTP port - DEFAULT_PROMETHEUS_EXPORTER_HTTP_PORT MetricsExporterPort int Logger *zerolog.Logger }
NATSServerConfig config used to creata a new NATSServer
func (*NATSServerConfig) DebugLogEnabled ¶
func (a *NATSServerConfig) DebugLogEnabled() bool
DebugLogEnabled true if debug logging is enabled
func (*NATSServerConfig) ServerOpts ¶
func (a *NATSServerConfig) ServerOpts() (*natsserver.Options, error)
ServerOpts converts the config to a ServerOpts that can be used to create a new nats.Server. It ensures the server is started up with the HTTP monitor and configured to join a cluster. If no routes are specified, then it adds itself as a route - assuming that this is a cluster seed node.
func (*NATSServerConfig) TraceLogEnabled ¶
func (a *NATSServerConfig) TraceLogEnabled() bool
TraceLogEnabled true if trace logging is enabled