Skip to content

Commit

Permalink
some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Sep 26, 2022
1 parent 054cae0 commit 4c4ede2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@ go.work
.DS_Store

profile.out
coverage.txt
coverage.txt
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix
2 changes: 1 addition & 1 deletion pkg/rabbitmq/bus/rabbitmq-bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type rabbitMQBus struct {
logger logger.Logger
}

func NewRabbitMQBus(log logger.Logger, consumers []consumer.Consumer) bus.Bus {
func NewRabbitMQBus(log logger.Logger, consumers ...consumer.Consumer) bus.Bus {
return &rabbitMQBus{logger: log, consumers: consumers}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/rabbitmq/consumer/rabbitmq_consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Test_Consume_Message(t *testing.T) {
var consumers []consumer.Consumer
consumers = append(consumers, rabbitmqConsumer)

b := bus.NewRabbitMQBus(defaultLogger.Logger, consumers)
b := bus.NewRabbitMQBus(defaultLogger.Logger, consumers...)
err = b.Start(context.Background())
if err != nil {
return
Expand Down Expand Up @@ -120,7 +120,7 @@ func Test_Consume_Default_Message(t *testing.T) {
var consumers []consumer.Consumer
consumers = append(consumers, rabbitmqConsumer)

b := bus.NewRabbitMQBus(defaultLogger.Logger, consumers)
b := bus.NewRabbitMQBus(defaultLogger.Logger, consumers...)
err = b.Start(context.Background())
if err != nil {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func NewRabbitMQWorkerWorker(infra *infrastructure.InfrastructureConfigurations) web.Worker {
rabbitMQBus := rabbitmqBus.NewRabbitMQBus(infra.Log, infra.Consumers)
rabbitMQBus := rabbitmqBus.NewRabbitMQBus(infra.Log, infra.Consumers...)

return web.NewBackgroundWorker(func(ctx context.Context) error {
err := rabbitMQBus.Start(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func NewRabbitMQWorkerWorker(infra *infrastructure.InfrastructureConfiguration) web.Worker {
bus := rabbitmqBus.NewRabbitMQBus(infra.Log, infra.Consumers)
bus := rabbitmqBus.NewRabbitMQBus(infra.Log, infra.Consumers...)
return web.NewBackgroundWorker(func(ctx context.Context) error {
err := bus.Start(ctx)
if err != nil {
Expand Down

0 comments on commit 4c4ede2

Please sign in to comment.