Documentation
¶
Index ¶
- func BuildJSONHandler[T any, O any](handler JSONMessageHandler[T, O]) (message.HandlerFunc, error)
- func BuildProtoHandler[T proto.Message](prototype T, handler ProtoMessageHandler[T], ...) (message.HandlerFunc, error)
- func EnsureProtoPrototype[T proto.Message](candidate T) (T, error)
- type JSONHandlerRegistration
- type JSONMessageContext
- type JSONMessageHandler
- type JSONMessageOutput
- type ProtoHandlerOption
- type ProtoHandlerOptions
- type ProtoHandlerRegistration
- type ProtoMessageContext
- type ProtoMessageFactory
- type ProtoMessageHandler
- type ProtoMessageOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildJSONHandler ¶
func BuildJSONHandler[T any, O any](handler JSONMessageHandler[T, O]) (message.HandlerFunc, error)
BuildJSONHandler converts a typed JSON handler into a Watermill handler.
func BuildProtoHandler ¶
func BuildProtoHandler[T proto.Message](prototype T, handler ProtoMessageHandler[T], validate func(proto.Message) error, factory ProtoMessageFactory) (message.HandlerFunc, error)
BuildProtoHandler converts the typed handler into a Watermill handler using the provided factory.
func EnsureProtoPrototype ¶
Types ¶
type JSONHandlerRegistration ¶
type JSONHandlerRegistration[T any, O any] struct { Name string ConsumeQueue string PublishQueue string Handler JSONMessageHandler[T, O] }
JSONHandlerRegistration wires a typed JSON handler to the router.
type JSONMessageContext ¶
type JSONMessageContext[T any] struct { Payload T Metadata metadatapkg.Metadata }
JSONMessageContext exposes the incoming payload and metadata for JSON handlers.
func (JSONMessageContext[T]) CloneMetadata ¶
func (c JSONMessageContext[T]) CloneMetadata() metadatapkg.Metadata
CloneMetadata copies the current metadata map so handlers can mutate headers safely.
type JSONMessageHandler ¶
type JSONMessageHandler[T any, O any] func(ctx context.Context, event JSONMessageContext[T]) ([]JSONMessageOutput[O], error)
JSONMessageHandler processes a JSON payload and returns the events to publish.
type JSONMessageOutput ¶
type JSONMessageOutput[T any] struct { Message T Metadata metadatapkg.Metadata }
JSONMessageOutput represents an event emitted by a JSON handler.
type ProtoHandlerOption ¶
type ProtoHandlerOption func(*protoHandlerOptions)
ProtoHandlerOption customises handler registration.
func WithPublishMessageTypes ¶
func WithPublishMessageTypes(msgs ...proto.Message) ProtoHandlerOption
WithPublishMessageTypes registers extra proto schemas emitted by this handler. Use this when the handler may emit multiple message types.
type ProtoHandlerOptions ¶
ProtoHandlerOptions exposes the resolved handler configuration to callers.
func ApplyProtoHandlerOptions ¶
func ApplyProtoHandlerOptions(opts []ProtoHandlerOption) ProtoHandlerOptions
ApplyProtoHandlerOptions resolves the supplied options into a concrete configuration.
type ProtoHandlerRegistration ¶
type ProtoHandlerRegistration[T proto.Message] struct { Name string ConsumeQueue string PublishQueue string Handler ProtoMessageHandler[T] Options []ProtoHandlerOption ValidateOutgoing bool }
ProtoHandlerRegistration configures a typed protobuf handler that automatically unmarshals incoming payloads and marshals emitted events.
type ProtoMessageContext ¶
type ProtoMessageContext[T proto.Message] struct { Payload T Metadata metadatapkg.Metadata }
ProtoMessageContext provides strongly typed access to the incoming message payload.
func (ProtoMessageContext[T]) CloneMetadata ¶
func (c ProtoMessageContext[T]) CloneMetadata() metadatapkg.Metadata
CloneMetadata returns a copy of the current metadata map so handlers can safely mutate headers for outgoing events without touching the original map.
type ProtoMessageFactory ¶
ProtoMessageFactory converts proto payloads into Watermill messages.
type ProtoMessageHandler ¶
type ProtoMessageHandler[T proto.Message] func(ctx context.Context, event ProtoMessageContext[T]) ([]ProtoMessageOutput, error)
ProtoMessageHandler processes a typed protobuf payload and returns the events to emit.
type ProtoMessageOutput ¶
type ProtoMessageOutput struct {
Message proto.Message
Metadata metadatapkg.Metadata
}
ProtoMessageOutput describes an event that should be emitted after the handler succeeds.