messaging

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTestProducerTimeout = errors.New("timeout")

Functions

func Initialize

func Initialize()

func NewConsumer

func NewConsumer(qc QueueConsumer)

Types

type Producer

type Producer struct {
	// contains filtered or unexported fields
}

func NewProducer

func NewProducer(topicName string) *Producer

func (*Producer) Publish

func (p *Producer) Publish(ctx context.Context, action string, message any) error

type ProviderMessage

type ProviderMessage struct {
	Id       uuid.UUID   `json:"id"`
	Origin   string      `json:"origin"`
	Action   string      `json:"action"`
	TenantId string      `json:"tenantId"`
	UserId   string      `json:"userId"`
	Message  interface{} `json:"message"`
	// contains filtered or unexported fields
}

func (*ProviderMessage) DecodeAndValidateMessage

func (msg *ProviderMessage) DecodeAndValidateMessage(model interface{}) error

DecodeAndValidateMessage transform interface into ProviderMessage and validate the struct

func (*ProviderMessage) DecodeMessage

func (msg *ProviderMessage) DecodeMessage(model interface{}) error

DecodeMessage transform interface into ProviderMessage

func (*ProviderMessage) String

func (msg *ProviderMessage) String() string

String convert struct into json string

type QueueConsumer

type QueueConsumer interface {
	Consume(ctx context.Context, providerMessage *ProviderMessage) error
	QueueName() string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL