Documentation ¶
Index ¶
- Constants
- func AddNatsLogHook(nc NatsWriter, log *logrus.Entry, subject string, levels ...logrus.Level)
- func ConfigureNatsConnection(config *NatsConfig, log logrus.FieldLogger) (*nats.Conn, error)
- func ConfigureNatsStreaming(config *NatsConfig, log logrus.FieldLogger) (stan.Conn, error)
- func ConnectToNats(config *NatsConfig, opts ...nats.Option) (*nats.Conn, error)
- func ConnectToNatsStreaming(nc *nats.Conn, config *NatsConfig, log logrus.FieldLogger) (stan.Conn, error)
- func ErrorHandler(log logrus.FieldLogger) nats.Option
- func LoadCAFromFiles(cafiles []string) (*x509.CertPool, error)
- func LoadCAFromValue(ca string) (*x509.CertPool, error)
- func LoadCertFromFiles(certFile, keyFile string) (tls.Certificate, error)
- func LoadCertFromValues(certPEM, keyPEM string) (tls.Certificate, error)
- func NatsRootCAs(tlsConf *tls.Config) nats.Option
- type NatsAuth
- type NatsClientConfig
- type NatsConfig
- type NatsHook
- type NatsWriter
- type TLSConfig
Constants ¶
View Source
const ( NatsAuthMethodUser = "user" NatsAuthMethodToken = "token" NatsAuthMethodTLS = "tls" )
Variables ¶
This section is empty.
Functions ¶
func AddNatsLogHook ¶
func ConfigureNatsConnection ¶
func ConfigureNatsConnection(config *NatsConfig, log logrus.FieldLogger) (*nats.Conn, error)
func ConfigureNatsStreaming ¶
func ConfigureNatsStreaming(config *NatsConfig, log logrus.FieldLogger) (stan.Conn, error)
func ConnectToNats ¶
func ConnectToNats(config *NatsConfig, opts ...nats.Option) (*nats.Conn, error)
func ConnectToNatsStreaming ¶
func ConnectToNatsStreaming(nc *nats.Conn, config *NatsConfig, log logrus.FieldLogger) (stan.Conn, error)
func ErrorHandler ¶
func ErrorHandler(log logrus.FieldLogger) nats.Option
func LoadCAFromFiles ¶ added in v0.64.0
func LoadCertFromFiles ¶ added in v0.64.0
func LoadCertFromFiles(certFile, keyFile string) (tls.Certificate, error)
func LoadCertFromValues ¶ added in v0.64.0
func LoadCertFromValues(certPEM, keyPEM string) (tls.Certificate, error)
func NatsRootCAs ¶
NatsRootCAs is a NATS helper option to provide the RootCAs pool from a tls.Config struct. If Secure is not already set this will set it as well.
Types ¶
type NatsClientConfig ¶
type NatsClientConfig struct { NatsConfig `mapstructure:",squash"` Subject string `mapstructure:"command_subject"` Group string `mapstructure:"command_group"` // StartAt will configure where the client should resume the stream: // - `all`: all the messages available // - `last`: from where the client left off // - `new`: all new messages for the client // - `first`: from the first message available (default) // - other: if it isn't one of the above fields, it will try and parse the param as a go duration (e.g. 30s, 1h) StartAt string `mapstructure:"start_at"` }
type NatsConfig ¶
type NatsConfig struct { TLS *TLSConfig `mapstructure:"tls_conf"` DiscoveryName string `mapstructure:"discovery_name" split_words:"true"` Servers []string `mapstructure:"servers"` Auth NatsAuth `mapstructure:"auth"` // for streaming ClusterID string `mapstructure:"cluster_id" split_words:"true"` ClientID string `mapstructure:"client_id" split_words:"true"` StartPos string `mapstructure:"start_pos" split_words:"true"` }
func (*NatsConfig) Fields ¶
func (c *NatsConfig) Fields() logrus.Fields
func (*NatsConfig) LoadServerNames ¶
func (c *NatsConfig) LoadServerNames() error
func (*NatsConfig) ServerString ¶
func (c *NatsConfig) ServerString() string
ServerString will build the proper string for nats connect
func (*NatsConfig) StartPoint ¶
func (c *NatsConfig) StartPoint() (stan.SubscriptionOption, error)
type NatsHook ¶
type NatsHook struct { Formatter logrus.Formatter LogLevels []logrus.Level // contains filtered or unexported fields }
NatsHook will emit logs to the subject provided
func NewNatsHook ¶
func NewNatsHook(conn NatsWriter, subject string, levels []logrus.Level) *NatsHook
NewNatsHook will create a logrus hook that will automatically send new info into the channel
func (*NatsHook) AddDynamicField ¶
AddDynamicField will call that method on each fire
type NatsWriter ¶
type TLSConfig ¶ added in v0.64.0
type TLSConfig struct { CAFiles []string `mapstructure:"ca_files" envconfig:"ca_files" json:"ca_files" yaml:"ca_files"` KeyFile string `mapstructure:"key_file" split_words:"true" json:"key_file" yaml:"key_file"` CertFile string `mapstructure:"cert_file" split_words:"true" json:"cert_file" yaml:"cert_file"` Cert string `mapstructure:"cert"` Key string `mapstructure:"key"` CA string `mapstructure:"ca"` Insecure bool `default:"false"` Enabled bool `default:"false"` }
Click to show internal directories.
Click to hide internal directories.