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

add strict flag for assert #329

Merged
merged 5 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions cmd/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ func ServeCmd() *cobra.Command {
},
}

// assert
cmd.Flags().Bool("ignore-asserts", false, "ignore-asserts mode")
_ = viper.BindPFlag("ignore-asserts", cmd.Flags().Lookup("ignore-asserts"))

// api
cmd.Flags().Int("api-size", 100, "size of the submission queue buffered channel")
cmd.Flags().String("api-http-addr", "0.0.0.0:8001", "http server address")
Expand Down
4 changes: 3 additions & 1 deletion internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"time"

"github.com/robfig/cron/v3"
"github.com/spf13/viper"
)

func Assert(cond bool, msg string) {
if !cond {
strict := viper.GetBool("ignore-asserts")
susarlanikhilesh marked this conversation as resolved.
Show resolved Hide resolved
if !strict && !cond {
susarlanikhilesh marked this conversation as resolved.
Show resolved Hide resolved
panic(msg)
}
}
Expand Down