Documentation
¶
Index ¶
- Constants
- Variables
- func ApiError(code codes.Code, msg any) []byte
- func Call[T proto.Message, U proto.Message](ctx context.Context, con *nats.Conn, middleware []Handler, ...) error
- func CallServerAPI[T proto.Message, U proto.Message](ctx context.Context, panicRecovery bool, errorHandler ErrorHandler, ...) error
- func ErrorResponse(m *nats.Msg, code codes.Code, msg any)
- func Listen[T proto.Message, U proto.Message](con *nats.Conn, panicRecovery bool, subList *sync.Map, middleware []Handler, ...) error
- func RecoverAPIpanic(msg *nats.Msg)
- type ErrorHandler
- type Handler
Constants ¶
View Source
const ( ErrorPrefix = "ERR\x01" // ErrorPrefix ERR(Start of Heading) Denotes an API error. ErrorSeparator = "\x02" // ErrorSeparator (Start of Text) Denotes the start of the API error message. )
Variables ¶
View Source
var DefaultHandler = make([]Handler, 0)
Functions ¶
func Call ¶
func Call[T proto.Message, U proto.Message](ctx context.Context, con *nats.Conn, middleware []Handler, errorHandler ErrorHandler, subject string, command T, ret U) error
Call provides the functionality to call NATS req/rep APIs
func CallServerAPI ¶
func ErrorResponse ¶
func RecoverAPIpanic ¶
func RecoverAPIpanic(msg *nats.Msg)
Types ¶
type ErrorHandler ¶
var DefaultErrorHandler ErrorHandler = func(err error, msg *nats.Msg) error { c := codes.Unknown ErrorResponse(msg, c, err.Error()) return fmt.Errorf("API call: %w", err) }
Click to show internal directories.
Click to hide internal directories.