Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading