Skip to content

Commit

Permalink
add strict flag for assert (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
susarlanikhilesh committed May 20, 2024
1 parent 4875c84 commit d5a4a3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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 {
ignoreAsserts := viper.GetBool("ignore-asserts")
if !ignoreAsserts && !cond {
panic(msg)
}
}
Expand Down

0 comments on commit d5a4a3d

Please sign in to comment.