Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NotFoundHandler = HandlerFunc(func(_ context.Context, _ jetstream.Msg) error { return peanats.Error{ Code: http.StatusNotFound, Message: "handler not found", Cause: nil, } })
Functions ¶
This section is empty.
Types ¶
type AccessLogOption ¶ added in v0.8.2
type AccessLogOption func(*accessLogParams)
func WithAccessLogLevel ¶ added in v0.8.2
func WithAccessLogLevel(level slog.Level) AccessLogOption
func WithAccessLogMessage ¶ added in v0.8.2
func WithAccessLogMessage(message string) AccessLogOption
type Consumer ¶
type Consumer struct { BaseContext context.Context Consumer JetstreamConsumer Handler Handler Executor func(func()) // contains filtered or unexported fields }
type Handler ¶
func ChainMiddleware ¶ added in v0.7.3
func ChainMiddleware(h Handler, mws ...Middleware) Handler
func HandleType ¶ added in v0.8.0
func HandleType[T any](h TypedHandler[T]) Handler
type HandlerFunc ¶ added in v0.7.2
type JetstreamConsumer ¶ added in v0.7.3
type JetstreamConsumer interface {
Consume(jetstream.MessageHandler, ...jetstream.PullConsumeOpt) (jetstream.ConsumeContext, error)
}
type Middleware ¶
func Router ¶ added in v0.7.3
func Router(routes ...Route) Middleware
func WithAccessLog ¶
func WithAccessLog(logger *slog.Logger, opts ...AccessLogOption) Middleware
WithAccessLog returns a middleware that logs access using the provided slog.Logger.
func WithAck ¶
func WithAck() Middleware
WithAck returns a middleware that ACKs the message after handling it successfully.
func WithAckOnArrival ¶ added in v0.9.3
func WithAckOnArrival() Middleware
WithAckOnArrival returns a middleware that ACKs the message immediately on arrival.
func WithErrorLog ¶
func WithErrorLog(logger *slog.Logger, propagate bool) Middleware
WithErrorLog returns a middleware that logs errors using the provided logger. If propagate is true, the error is propagated to the outer handler.
func WithNak ¶ added in v0.6.4
func WithNak() Middleware
WithNak returns a middleware that NAKs the message if the handler returns an error.
type TypedHandler ¶ added in v0.7.3
type TypedHandler[T any] interface { Serve(context.Context, TypedMessage[T]) error }
type TypedHandlerFunc ¶ added in v0.7.3
type TypedHandlerFunc[T any] func(peanats.TypedRequest[T]) error
func (TypedHandlerFunc[T]) Serve ¶ added in v0.7.3
func (f TypedHandlerFunc[T]) Serve(arg peanats.TypedRequest[T]) error
type TypedMessage ¶ added in v0.7.3
Click to show internal directories.
Click to hide internal directories.