Skip to content

Commit

Permalink
feat: add http package
Browse files Browse the repository at this point in the history
  • Loading branch information
allisson committed Dec 29, 2023
1 parent 89a40e7 commit 7060692
Show file tree
Hide file tree
Showing 17 changed files with 3,294 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ run-migration:
create-mocks:
@rm -rf mocks
mockery --all

.PHONY: swag-init
swag-init:
swag init -g cmd/psqlqueue/main.go
swag fmt

.PHONY: run-server
run-server:
go run cmd/psqlqueue/main.go server
32 changes: 32 additions & 0 deletions cmd/psqlqueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (

"github.com/allisson/psqlqueue/db/migrations"
"github.com/allisson/psqlqueue/domain"
"github.com/allisson/psqlqueue/http"
"github.com/allisson/psqlqueue/repository"
"github.com/allisson/psqlqueue/service"
)

func main() {
Expand All @@ -28,6 +31,35 @@ func main() {
return migrations.Migrate(cfg.DatabaseURL)
},
},
{
Name: "server",
Aliases: []string{"s"},
Usage: "run http server",
Action: func(c *cli.Context) error {
pool, err := repository.SetupDatabaseConnection(c.Context, cfg)
if err != nil {
return err
}
defer pool.Close()

// repositories
queueRepository := repository.NewQueue(pool)
messageRepository := repository.NewMessage(pool)

// services
queueService := service.NewQueue(queueRepository)
messageService := service.NewMessage(messageRepository, queueRepository)

// http handlers
queueHandler := http.NewQueueHandler(queueService)
messageHandler := http.NewMessageHandler(messageService)

// run http server
http.RunServer(c.Context, cfg, http.SetupRouter(logger, queueHandler, messageHandler))

return nil
},
},
},
}

Expand Down
Loading

0 comments on commit 7060692

Please sign in to comment.