Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶
func RegisterProvider(name string, builder providerBuildFunc)
RegisterProvider register a provider builder.
Types ¶
type Client ¶
type Client struct { ServiceName string Provider Provider Middleware []Middleware }
func (*Client) On ¶
func (c *Client) On(opts HandlerOptions) error
type Handler ¶
type Handler any
Handler is custom callback for subscriber. The handler function format is. func(ctx context.Context, custom CustomModel,m *Message) error
type HandlerOptions ¶
type HandlerOptions struct { Name string // ServiceName identify the service of Provider, will use this to find the service or Config ServiceName string // The function to invoke Handler Handler // Decode JSON objects from message body instead of protobuf. JSON bool }
HandlerOptions is the options for handler
type MessageHandler ¶
MessageHandler is the internal or raw message handler
type Middleware ¶
type Middleware interface { SubscribeInterceptor(next MessageHandler) MessageHandler PublishInterceptor(ctx context.Context, next PublishHandler) PublishHandler }
Middleware is an interface to provide subscriber and publisher interceptors
type Provider ¶
type Provider interface { woocoo.Server // GetMQType get the type name of message queue provider GetMQType() string Publish(ctx context.Context, opts PublishOptions, m *Message) error Subscribe(opts HandlerOptions, handler MessageHandler) error }
Provider is an interface for message queue provider. this is also a wrapper for the sdk of mq officer client.
type PublishHandler ¶
PublishHandler wraps a call to publish, for interception
type PublishOptions ¶
type RecoveryHandlerFunc ¶
type RecoveryHandlerFunc func(p interface{}) (err error)
RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.
type RecoveryMiddleware ¶
type RecoveryMiddleware struct {
RecoveryHandlerFunc RecoveryHandlerFunc
}
RecoveryMiddleware is middleware for recovering from panics
func (RecoveryMiddleware) PublishInterceptor ¶
func (o RecoveryMiddleware) PublishInterceptor(ctx context.Context, next PublishHandler) PublishHandler
PublishInterceptor adds recovery to the publisher
func (RecoveryMiddleware) SubscribeInterceptor ¶
func (o RecoveryMiddleware) SubscribeInterceptor(next MessageHandler) MessageHandler
SubscribeInterceptor returns a subscriber middleware with added logging via Zap