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 NatsRootCAs(tlsConf *tls.Config) nats.Option
- type NatsAuth
- type NatsClientConfig
- type NatsConfig
- type NatsHook
- type NatsWriter
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 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 *nconf.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 ¶
Click to show internal directories.
Click to hide internal directories.