chore: add timeout for db and add default param for new command (#137)

This commit is contained in:
Richard
2024-06-22 19:24:42 +08:00
committed by GitHub
parent b35d08d5d0
commit f6f8018dfb
4 changed files with 20 additions and 9 deletions

View File

@@ -3,7 +3,8 @@
## v1.8.2
- feat: support PostgreSQL
- feat: support config multiple databases
- chore(cli): generate project by adding branch name
- chore(cli): generate project by adding branch name, default is http server
- chore(db): add timeout for connect, read and write
## v1.8.1
- fix: GitHub workflow badge URL

View File

@@ -80,10 +80,16 @@ go get github.com/go-eagle/eagle/cmd/eagle
## Quick Start
```bash
# only gen a server with http
eagle new eagle-demo
# or
eagle new github.com/foo/eagle-demo
# gen a server with http and gRPC
eagle new -b=all eagle-demo
# or
eagle new github.com/foo/eagle-demo
# build
make build

View File

@@ -20,9 +20,9 @@ var CmdNew = &cobra.Command{
}
var (
repoURL string
branch string
defaultTimeout string
repoURL string
branch string
timeout string
)
func init() {
@@ -30,10 +30,14 @@ func init() {
repoURL = "https://github.com/go-eagle/eagle-layout.git"
}
defaultTimeout = "60s"
// default http, only include http server
branch = "http"
// default timeout
timeout = "60s"
CmdNew.Flags().StringVarP(&repoURL, "repo-url", "r", repoURL, "layout repo")
CmdNew.Flags().StringVarP(&branch, "branch", "b", branch, "repo branch name")
CmdNew.Flags().StringVarP(&defaultTimeout, "timeout", "t", defaultTimeout, "request timeout time")
CmdNew.Flags().StringVarP(&branch, "branch", "b", branch, "default is http server, empty is http and gRPC")
CmdNew.Flags().StringVarP(&timeout, "timeout", "t", timeout, "request timeout time")
}
func run(cmd *cobra.Command, args []string) {
@@ -41,7 +45,7 @@ func run(cmd *cobra.Command, args []string) {
if err != nil {
panic(err)
}
t, err := time.ParseDuration(defaultTimeout)
t, err := time.ParseDuration(timeout)
if err != nil {
panic(err)
}

View File

@@ -19,7 +19,7 @@ import (
var (
// Version is the version of the compiled software.
Version = "v0.17.0"
Version = "v0.18.0"
rootCmd = &cobra.Command{
Use: "eagle",