Skip to content

Commit

Permalink
chore: add timeout for db and add default param for new command
Browse files Browse the repository at this point in the history
  • Loading branch information
qloog committed Jun 22, 2024
1 parent b35d08d commit 1bce7bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 11 additions & 7 deletions cmd/eagle/internal/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,32 @@ var CmdNew = &cobra.Command{
}

var (
repoURL string
branch string
defaultTimeout string
repoURL string
branch string
timeout string
)

func init() {
if repoURL = os.Getenv("EAGLE_LAYOUT_REPO"); repoURL == "" {
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) {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
t, err := time.ParseDuration(defaultTimeout)
t, err := time.ParseDuration(timeout)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/eagle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1bce7bc

Please sign in to comment.