Documentation ¶
Index ¶
- func StreamNotificationInterceptor(recipients []notification.Sender, configs ...EndpointConfig) grpc.StreamServerInterceptor
- func UnaryNotificationInterceptor(recipients []notification.Sender, configs ...EndpointConfig) grpc.UnaryServerInterceptor
- type Config
- type EndpointConfig
- type EndpointOption
- type ShouldNotifyForErrFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamNotificationInterceptor ¶
func StreamNotificationInterceptor(recipients []notification.Sender, configs ...EndpointConfig) grpc.StreamServerInterceptor
The hook for streaming endpoints Assembles all endpoint configurations to one EndpointConfig and returns the hook function
func UnaryNotificationInterceptor ¶
func UnaryNotificationInterceptor(recipients []notification.Sender, configs ...EndpointConfig) grpc.UnaryServerInterceptor
The hook for unary endpoints Assembles all endpoint configurations to one EndpointConfig and returns the hook function
Types ¶
type Config ¶
type Config struct { CustomShouldNotify ShouldNotifyForErrFunc SkipErrors bool NotifyOnSuccess bool ErrorCodes []codes.Code }
func (Config) ShouldNotifyForErr ¶
ShouldNotify determines whether a notification should be sent for the provided error. The default behaviour can be overridden by setting a custom decision function with UseShouldNotifyForErrFunc(ShouldNotify).
type EndpointConfig ¶
func NewEndpointConfig ¶
func NewEndpointConfig(funcName string, opts ...EndpointOption) EndpointConfig
The default options for an endpoint is * Send notifications on error only * Send notification on all error codes
type EndpointOption ¶
type EndpointOption func(*Config)
func DoNotifyOnSuccess ¶
func DoNotifyOnSuccess() EndpointOption
Set if a message notification should be sent if the request was handled successfully.
func DoSkipErrors ¶
func DoSkipErrors() EndpointOption
Set to skip message notifications when a gRPC error occurs.
func NotifyOnlyOn ¶
func NotifyOnlyOn(codes []codes.Code) EndpointOption
If this is set a slack notification will only be sent if any of these gRPC errors occurs. If this is not set a slack message will be sent on any gRPC error that occurs.
func UseShouldNotifyForErrFunc ¶
func UseShouldNotifyForErrFunc(f ShouldNotifyForErrFunc) EndpointOption
UseShouldNotifyForErrFunc will use the provided function to determine whether a a slack notification should be sent for a given error.