Skip to content

Commit

Permalink
feat: ✨ removing repository and uow for gorm DataAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Nov 28, 2023
1 parent 08a5c17 commit dfa600b
Show file tree
Hide file tree
Showing 277 changed files with 4,616 additions and 3,566 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/config/config_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/config/environment"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants"
typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper"
typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/typemapper"

"emperror.dev/errors"
"github.com/caarlos0/env/v8"
Expand Down
20 changes: 20 additions & 0 deletions internal/pkg/config/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func ConfigAppEnv(environments ...Environment) Environment {

setRootWorkingDirectoryEnvironment()

fixTestEnvironmentWorkingDirectory()

manualEnv := os.Getenv(constants.AppEnv)

if manualEnv != "" {
Expand All @@ -59,6 +61,10 @@ func (env Environment) IsProduction() bool {
return env == Production
}

func (env Environment) IsTest() bool {
return env == Test
}

func (env Environment) GetEnvironmentName() string {
return string(env)
}
Expand All @@ -67,6 +73,7 @@ func EnvString(key, fallback string) string {
if value, ok := syscall.Getenv(key); ok {
return value
}

return fallback
}

Expand Down Expand Up @@ -123,6 +130,19 @@ func setRootWorkingDirectoryEnvironment() {
viper.Set(constants.AppRootPath, absoluteRootWorkingDirectory)
}

func fixTestEnvironmentWorkingDirectory() {
currentWD, _ := os.Getwd()
log.Printf("Current test working directory is: %s", currentWD)

rootDir := viper.GetString(constants.AppRootPath)
if rootDir != "" {
_ = os.Chdir(rootDir)

newWD, _ := os.Getwd()
log.Printf("New test working directory is: %s", newWD)
}
}

func getRootDirectoryFromProjectName(pn string) string {
// set root working directory of our app in the viper
// https://stackoverflow.com/a/47785436/581476
Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/core/cqrs/tx_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cqrs

// https://www.mohitkhare.com/blog/go-naming-conventions/
type ITxRequest interface {
IsTxRequest() bool
}
12 changes: 12 additions & 0 deletions internal/pkg/core/messaging/bus/bus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package bus

import (
consumer2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/consumer"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/producer"
)

type Bus interface {
producer.Producer
consumer2.BusControl
consumer2.ConsumerConnector
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package consumer
import (
"context"

"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/types"
)

type Consumer interface {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package consumer

import (
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/types"
)

type ConsumerConnector interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package consumer
import (
"context"

"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/types"
)

type ConsumerHandler interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package consumer
import (
"context"

"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types"
"github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/messaging/types"
)

type BusControl interface {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dfa600b

Please sign in to comment.