Skip to content

Commit

Permalink
Simplified Cinterface providers and inbound communication handlers un…
Browse files Browse the repository at this point in the history
…der one single 'infra' layer
  • Loading branch information
pkritiotis committed Aug 2, 2024
1 parent 8bad1e4 commit 43b4b5c
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 36 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ Go Climb follows the group-by-layer structure:
│   │   ├── crag.go
│   │   ├── mock_repository.go
│   │   └── repository.go
│   ├── inputports
│   ├── infra
│   │   ├── http
│   │   │   ├── crag
│   │   │   └── server.go
│   │   └── sevices.go
│   ├── outputadapters
│   │   ├── notification
│   │   │   └── console
│   │   ├── services.go
Expand All @@ -72,8 +70,6 @@ Go Climb follows the group-by-layer structure:
- `docs` contains documentation about the application
- `internal` contains the main implementation of our application. It consists of the three layers of clean architecture + shared utility code under `pkg/`
- infra
- outputadapters
- inputports
- app
- domain
- pkg
Expand Down
11 changes: 5 additions & 6 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ package main

import (
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/inputports"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/time"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/pkg/uuid"
)

func main() {
interfaceAdapterServices := interfaceadapters.NewServices()
infraProviders := infra.NewInfraProviders()
tp := time.NewTimeProvider()
up := uuid.NewUUIDProvider()
appServices := app.NewServices(interfaceAdapterServices.CragRepository, interfaceAdapterServices.NotificationService, up, tp)
inputPortsServices := inputports.NewServices(appServices)
inputPortsServices.Server.ListenAndServe(":8080")
appServices := app.NewServices(infraProviders.CragRepository, infraProviders.NotificationService, up, tp)
infraHTTPServer := infra.NewHTTPServer(appServices)
infraHTTPServer.ListenAndServe(":8080")
}
1 change: 0 additions & 1 deletion docs/CleanArchitecture.drawio

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/gorilla/mux"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/inputports/http/crag"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/http/crag"
)

// Server Represents the http server running for this service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
// Package interfaceadapters contains the services of the interface adapters
package interfaceadapters
// Package infra contains the services of the interface adapters
package infra

import (
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/app/notification"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/domain/crag"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters/notification/console"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/interfaceadapters/storage/memory"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/http"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/notification/console"
"github.com/pkritiotis/go-climb-clean-architecture-example/internal/infra/storage/memory"
)

// Services contains the exposed services of interface adapters
type Services struct {
NotificationService notification.Service
CragRepository crag.Repository
Server *http.Server
}

// NewServices Instantiates the interface adapter services
func NewServices() Services {
// NewInfraProviders Instantiates the infra services
func NewInfraProviders() Services {
return Services{
NotificationService: console.NewNotificationService(),
CragRepository: memory.NewRepo(),
}
}

// NewHTTPServer creates a new server
func NewHTTPServer(appServices app.Services) *http.Server {
return http.NewServer(appServices)
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 0 additions & 17 deletions internal/inputports/sevices.go

This file was deleted.

0 comments on commit 43b4b5c

Please sign in to comment.