Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTestProducerTimeout = errors.New("timeout")
Functions ¶
func Initialize ¶
func Initialize()
func NewConsumer ¶
func NewConsumer(qc QueueConsumer)
Types ¶
type OriginalMessage ¶ added in v0.1.3
type OriginalMessage interface {
// Ack acknowledges the message.
Ack() error
// Nack rejects the message.
// If requeue is true, the message will be put back in the original queue.
// If requeue is false, the message will be discarded or sent to a DLQ.
Nack(requeue bool, err error) error
}
OriginalMessage defines the interface for acknowledging or rejecting a message from a message broker.
type Producer ¶
type Producer struct {
// contains filtered or unexported fields
}
func NewProducer ¶
type ProviderMessage ¶
type ProviderMessage struct {
ID uuid.UUID `json:"id"`
Origin string `json:"origin"`
Action string `json:"action"`
Message any `json:"message"`
AuthContext *security.AuthenticationContext `json:"authenticationContext"`
// contains filtered or unexported fields
}
func NewProviderMessage ¶
func NewProviderMessage(ctx context.Context, action string, message any) *ProviderMessage
NewProviderMessage returns a new ProviderMessage
func (*ProviderMessage) Ack ¶ added in v0.1.3
func (msg *ProviderMessage) Ack() error
Ack acknowledges the message.
func (*ProviderMessage) DecodeAndValidateMessage ¶
func (msg *ProviderMessage) DecodeAndValidateMessage(model any) error
DecodeAndValidateMessage transform interface into ProviderMessage and validate the struct
func (*ProviderMessage) DecodeMessage ¶
func (msg *ProviderMessage) DecodeMessage(model any) error
DecodeMessage transform interface into ProviderMessage
func (*ProviderMessage) Nack ¶ added in v0.1.3
func (msg *ProviderMessage) Nack(requeue bool, err error) error
Nack rejects the message. If requeue is true, the message will be put back in the original queue. If requeue is false, the message will be discarded or sent to a DLQ.
func (*ProviderMessage) String ¶
func (msg *ProviderMessage) String() string
String convert struct into JSON string
type QueueConfiguration ¶ added in v0.1.3
type QueueConfiguration struct {
TopicName string
}
type QueueConsumer ¶
type QueueConsumer interface {
// Consume processes a ProviderMessage in a given context and returns an error if the processing fails.
Consume(ctx context.Context, providerMessage *ProviderMessage) error
// QueueName retrieves the name of the queue associated with the consumer.
QueueName() string
}
QueueConsumer defines an interface for consuming messages from a queue and managing the queue's name.
type QueueConsumerConfig ¶ added in v0.1.3
type QueueConsumerConfig interface {
QueueConsumer
// Config returns the queue configuration details by providing access to a QueueConfiguration object.
Config() *QueueConfiguration
}
QueueConsumerConfig combines queue consumption capabilities with access to queue configuration details.
type TestProducer ¶
type TestProducer[T any] struct { // contains filtered or unexported fields }
TestProducer is a contract to test messaging producer
func NewTestProducer ¶
func NewTestProducer[T any](producerFn func() error, testQueue string, timeoutInSeconds uint8) *TestProducer[T]
NewTestProducer returns a pointer of TestProducer
func (*TestProducer[T]) Execute ¶
func (p *TestProducer[T]) Execute() (response *T, err error)
Execute returns a T pointer or error in test execution