Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var WorkerPackage = do.Package( do.Lazy(rabbitmq.ProvideRabbitMQConfig), do.Lazy(rabbitmq.NewRabbitMQService), do.Lazy(NewProducerWorker), do.Lazy(NewConsumerWorker), )
WorkerPackage provides worker services to the dependency injector This package demonstrates how to organize worker services using the samber/do library.
Functions ¶
This section is empty.
Types ¶
type ConsumerWorker ¶
type ConsumerWorker struct {
// contains filtered or unexported fields
}
ConsumerWorker is a worker that consumes messages from RabbitMQ This struct demonstrates how to implement a consumer worker with dependency injection.
func NewConsumerWorker ¶
func NewConsumerWorker(injector do.Injector) (*ConsumerWorker, error)
NewConsumerWorker creates a new consumer worker instance This function demonstrates how to initialize a consumer with dependency injection.
func (*ConsumerWorker) Shutdown ¶
func (w *ConsumerWorker) Shutdown() error
Shutdown stops the consumer worker This method demonstrates how to stop a consumer worker with dependency injection.
func (*ConsumerWorker) Start ¶
func (w *ConsumerWorker) Start() error
Start starts the consumer worker This method demonstrates how to start a consumer worker with dependency injection.
type ProducerWorker ¶
type ProducerWorker struct {
// contains filtered or unexported fields
}
ProducerWorker is a worker that produces messages to RabbitMQ This struct demonstrates how to implement a producer worker with dependency injection.
func NewProducerWorker ¶
func NewProducerWorker(injector do.Injector) (*ProducerWorker, error)
NewProducerWorker creates a new producer worker instance This function demonstrates how to initialize a producer with dependency injection.
func (*ProducerWorker) Shutdown ¶
func (w *ProducerWorker) Shutdown() error
Shutdown stops the producer worker This method demonstrates how to stop a producer worker with dependency injection.
func (*ProducerWorker) Start ¶
func (w *ProducerWorker) Start() error
Start starts the producer worker This method demonstrates how to start a producer worker with dependency injection.
type UserPayload ¶
UserPayload represents the user data in the message.
type WorkerMessage ¶
type WorkerMessage struct {
Action string `json:"action"`
Payload interface{} `json:"payload"`
ID string `json:"id"`
}
WorkerMessage represents the message structure for the workers.