thanks for provide this layout, but when i try my first project(name it blog), i find some issues:
-
kratos new blog
does not rename api/helloworld
to api/blog
, but cmd/helloworld
renamed to cmd/blog
as expected.
-
for multi models, the folder structure has no demo. How about group them in folder by model in api? but this change let package name v1
no longer work. same consideration to biz
, data
, service
.
├── api
│ └── blog
│ └── v1
│ └── error_reason
│ ├── error_reason.proto
│ ├── error_reason.pb.go
│ ├── error_reason.swagger.json
│ └── article
│ ├── article.proto
│ ├── article.pb.go
│ ├── article.swagger.json
│ ├── article_grpc.pb.go
│ └── article_http.pb.go
│ └── comment
│ ├── comment.proto
│ ├── comment.pb.go
│ ├── comment.swagger.json
│ ├── comment_grpc.pb.go
│ └── comment_http.pb.go
- how about move
conf
and server
to the root folder? unlike biz
, data
, service
which is model level, they are project level IMO.
├── internal
│ ├── biz
│ │ ├── README.md
│ │ ├── biz.go
│ │ └── greeter.go
│ ├── conf // move to project root folder as it is project level?
│ │ ├── conf.pb.go
│ │ └── conf.proto
│ ├── data
│ │ ├── README.md
│ │ ├── data.go
│ │ └── greeter.go
│ ├── server // move to project root folder as it is project level?
│ │ ├── grpc.go
│ │ ├── http.go
│ │ └── server.go
│ └── service
│ ├── README.md
│ ├── greeter.go
│ └── service.go
- register muli service
multi models means multi service, how to register multi services to one server? below should work,
but they are hard coded, not sure is there a better way?
func NewHTTPServer(
c *conf.Server,
greeter *service.GreeterService,
article *service.ArticleService,
comment *service.CommentService,
logger log.Logger,
) *http.Server {
// ... omited
srv := http.NewServer(opts...)
v1.RegisterGreeterHTTPServer(srv, greeter)
v1.RegisterArticleHTTPServer(srv, article)
v1.RegisterCommentHTTPServer(srv, comment)
return srv
}
I know there is a examples/blog but it is too simple only have one model,
maybe we can make it more realistic to show more feature and best practise of use kartos?
thanks.