Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
OldSmokeGun committed Oct 12, 2024
2 parents 2923f58 + 754e9b3 commit 16a9dfd
Show file tree
Hide file tree
Showing 99 changed files with 352 additions and 185 deletions.
6 changes: 3 additions & 3 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ vars:
# wire
WIRE_ENTRY_DIR: ./internal/command
# swagger
API_SWAGGER_SCAN_DIR: internal/app/adapter/server/http
API_SWAGGER_SCAN_DIR: internal/app/facade/server/http
API_SWAGGER_SCAN_ENTRY: http.go
API_SWAGGER_OUT_DIR: internal/app/adapter/server/http/api/docs
API_SWAGGER_OUT_DIR: internal/app/facade/server/http/api/docs
# proto
API_PROTO_GENERATE_FILE: internal/app/adapter/server/grpc/api/generate.go
API_PROTO_GENERATE_FILE: internal/app/facade/server/grpc/api/generate.go

tasks:
build:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/google/wire v0.6.0
github.com/hashicorp/consul/api v1.29.2
github.com/jackc/pgx/v5 v5.6.0
github.com/json-iterator/go v1.1.12
github.com/labstack/echo/v4 v4.12.0
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/mattn/go-sqlite3 v1.14.22
Expand Down Expand Up @@ -125,6 +126,8 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -340,6 +341,8 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -417,9 +420,12 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
Expand Down
15 changes: 0 additions & 15 deletions internal/app/adapter/adapter.go

This file was deleted.

4 changes: 2 additions & 2 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package app
import (
"github.com/google/wire"

"go-scaffold/internal/app/adapter"
"go-scaffold/internal/app/controller"
"go-scaffold/internal/app/facade"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
)

var ProviderSet = wire.NewSet(
adapter.ProviderSet,
facade.ProviderSet,
controller.ProviderSet,
usecase.ProviderSet,
repository.ProviderSet,
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"go-scaffold/internal/app/domain"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
"go-scaffold/pkg/validator"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/account_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"

"go-scaffold/internal/app/repository"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type AccountPermissionController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/account_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/service"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type AccountTokenController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/greet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/pkg/errors"

berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type GreetController struct{}
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"go-scaffold/internal/app/domain"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type PermissionController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/segmentio/kafka-go"

"go-scaffold/internal/config"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type ProducerController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"go-scaffold/internal/app/domain"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type ProductController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"go-scaffold/internal/app/domain"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
)

type RoleController struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/app/controller/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"go-scaffold/internal/app/domain"
"go-scaffold/internal/app/repository"
"go-scaffold/internal/app/usecase"
berr "go-scaffold/internal/pkg/errors"
berr "go-scaffold/internal/errors"
"go-scaffold/pkg/validator"
)

Expand Down
17 changes: 17 additions & 0 deletions internal/app/facade/adapter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package facade

import (
"github.com/google/wire"

"go-scaffold/internal/app/facade/cron"
"go-scaffold/internal/app/facade/kafka"
"go-scaffold/internal/app/facade/scripts"
"go-scaffold/internal/app/facade/server"
)

var ProviderSet = wire.NewSet(
cron.ProviderSet,
server.ProviderSet,
kafka.ProviderSet,
scripts.ProviderSet,
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/google/wire"
"github.com/robfig/cron/v3"

"go-scaffold/internal/app/adapter/cron/job"
"go-scaffold/internal/app/adapter/cron/scheduler"
"go-scaffold/internal/app/facade/cron/job"
"go-scaffold/internal/app/facade/cron/scheduler"
clog "go-scaffold/pkg/log/cron"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scheduler
import (
"github.com/robfig/cron/v3"

"go-scaffold/internal/app/adapter/cron/job"
"go-scaffold/internal/app/facade/cron/job"
"go-scaffold/internal/config"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/segmentio/kafka-go"

"go-scaffold/internal/app/adapter/kafka/handler"
"go-scaffold/internal/app/facade/kafka/handler"
"go-scaffold/internal/config"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/google/wire"

"go-scaffold/internal/app/adapter/kafka/consumer"
"go-scaffold/internal/app/adapter/kafka/handler"
"go-scaffold/internal/app/facade/kafka/consumer"
"go-scaffold/internal/app/facade/kafka/handler"
)

var ProviderSet = wire.NewSet(
Expand Down
39 changes: 39 additions & 0 deletions internal/app/facade/scripts/example_script.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package scripts

import (
"fmt"

jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"go-scaffold/internal/app/controller"
)

type ExampleCmd struct {
controller *controller.GreetController
}

func NewExampleCmd(
controller *controller.GreetController,
) *ExampleCmd {
return &ExampleCmd{
controller: controller,
}
}

func (c *ExampleCmd) Run(cmd *cobra.Command) error {
ret, err := c.controller.Hello(cmd.Context(), controller.GreetHelloRequest{Name: "Example"})
if err != nil {
return err
}

s, err := jsoniter.MarshalToString(ret)
if err != nil {
return errors.WithStack(err)
}

fmt.Println(s)

return nil
}
8 changes: 8 additions & 0 deletions internal/app/facade/scripts/scripts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package scripts

import "github.com/google/wire"

var ProviderSet = wire.NewSet(
// scripts
NewExampleCmd,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package internal.app.adapter.grpc.api.v1.greet;

option go_package = "go-scaffold/internal/app/adapter/grpc/api/v1;v1";
option go_package = "go-scaffold/internal/app/facade/grpc/api/v1;v1";

service Greet {
rpc Hello (GreetHelloRequest) returns (GreetHelloResponse) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package internal.app.adapter.grpc.api.v1.permission;

option go_package = "go-scaffold/internal/app/adapter/grpc/api/v1;v1";
option go_package = "go-scaffold/internal/app/facade/grpc/api/v1;v1";

service Permission {
rpc Create (PermissionCreateRequest) returns (PermissionCreateResponse) {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package internal.app.adapter.grpc.api.v1.product;

option go_package = "go-scaffold/internal/app/adapter/grpc/api/v1;v1";
option go_package = "go-scaffold/internal/app/facade/grpc/api/v1;v1";

service Product {
rpc Create (ProductCreateRequest) returns (ProductCreateResponse) {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package internal.app.adapter.grpc.api.v1.role;

option go_package = "go-scaffold/internal/app/adapter/grpc/api/v1;v1";
option go_package = "go-scaffold/internal/app/facade/grpc/api/v1;v1";

import "v1/permission.proto";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package internal.app.adapter.grpc.api.v1.user;

option go_package = "go-scaffold/internal/app/adapter/grpc/api/v1;v1";
option go_package = "go-scaffold/internal/app/facade/grpc/api/v1;v1";

import "v1/role.proto";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/google/wire"

v1api "go-scaffold/internal/app/adapter/server/grpc/api/v1"
v1handler "go-scaffold/internal/app/adapter/server/grpc/handler/v1"
"go-scaffold/internal/app/adapter/server/grpc/router"
v1api "go-scaffold/internal/app/facade/server/grpc/api/v1"
v1handler "go-scaffold/internal/app/facade/server/grpc/handler/v1"
"go-scaffold/internal/app/facade/server/grpc/router"
"go-scaffold/internal/config"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"log/slog"

v1 "go-scaffold/internal/app/adapter/server/grpc/api/v1"
"go-scaffold/internal/app/adapter/server/grpc/pkg/errors"
"go-scaffold/internal/app/controller"
v1 "go-scaffold/internal/app/facade/server/grpc/api/v1"
"go-scaffold/internal/app/facade/server/grpc/pkg/errors"
)

type GreetHandler struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"log/slog"

v1 "go-scaffold/internal/app/adapter/server/grpc/api/v1"
"go-scaffold/internal/app/adapter/server/grpc/pkg/errors"
"go-scaffold/internal/app/controller"
v1 "go-scaffold/internal/app/facade/server/grpc/api/v1"
"go-scaffold/internal/app/facade/server/grpc/pkg/errors"
)

type PermissionHandler struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"log/slog"

v1 "go-scaffold/internal/app/adapter/server/grpc/api/v1"
"go-scaffold/internal/app/adapter/server/grpc/pkg/errors"
"go-scaffold/internal/app/controller"
v1 "go-scaffold/internal/app/facade/server/grpc/api/v1"
"go-scaffold/internal/app/facade/server/grpc/pkg/errors"
)

type ProductHandler struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"log/slog"

v1 "go-scaffold/internal/app/adapter/server/grpc/api/v1"
"go-scaffold/internal/app/adapter/server/grpc/pkg/errors"
"go-scaffold/internal/app/controller"
v1 "go-scaffold/internal/app/facade/server/grpc/api/v1"
"go-scaffold/internal/app/facade/server/grpc/pkg/errors"
)

type RoleHandler struct {
Expand Down
Loading

0 comments on commit 16a9dfd

Please sign in to comment.