Documentation ¶
Index ¶
- func ExecMiddlewareChain(f sockets.HandlerFunc, m []sockets.MiddlewareFunc) sockets.HandlerFunc
- func Logger(cfg *LoggerConfig) sockets.MiddlewareFunc
- func Metrics() sockets.MiddlewareFunc
- func PanicHandler(next sockets.HandlerFunc) sockets.HandlerFunc
- func Timeout(cfg *TimeoutConfig) sockets.MiddlewareFunc
- type LoggerConfig
- type TimeoutConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecMiddlewareChain ¶
func ExecMiddlewareChain(f sockets.HandlerFunc, m []sockets.MiddlewareFunc) sockets.HandlerFunc
ExecMiddlewareChain builds the global middleware chain recursively, functions are first class.
func Logger ¶
func Logger(cfg *LoggerConfig) sockets.MiddlewareFunc
Logger will log the entire received message.
func Metrics ¶
func Metrics() sockets.MiddlewareFunc
Metrics contains basic example metrics that can be captured and pulled into prometheus.
You would most likely implement your own version of this.
func PanicHandler ¶
func PanicHandler(next sockets.HandlerFunc) sockets.HandlerFunc
PanicHandler will handle panics and log the error allowing the service to recover.
func Timeout ¶
func Timeout(cfg *TimeoutConfig) sockets.MiddlewareFunc
Timeout can be used to set a timeout on requests sent to listeners.
Types ¶
type LoggerConfig ¶
LoggerConfig holds configuration for a middleware based logger. This is used to output detail of the messages received.
func NewLoggerConfig ¶
func NewLoggerConfig() *LoggerConfig
NewLoggerConfig will setup a new LoggerConfig with a default skipper.
func (*LoggerConfig) AddSkipper ¶
func (l *LoggerConfig) AddSkipper(fn func(msg *sockets.Message) bool)
AddSkipper will add a custom skipper function to the logger, you may want to skip some messages but not all, perhaps by message key or only logging every n events.
type TimeoutConfig ¶
type TimeoutConfig struct { // Skipper, if true will skip setting timeouts for the request. Skipper func(msg *sockets.Message) bool Timeout time.Duration }
TimeoutConfig contains configuration settings for timeing out requests sent to listeners.
func NewTimeoutConfig ¶
func NewTimeoutConfig() *TimeoutConfig
NewTimeoutConfig will setup a new timeout config with default values. This sets the skipper to always return false (don't skip any requests) and the default timeout of 30 seconds.