Skip to content

Commit

Permalink
allow boolean command line arguments to have a value
Browse files Browse the repository at this point in the history
  • Loading branch information
ddowker committed Sep 18, 2024
1 parent 3c7f3d3 commit b136b0f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions broker/client/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (r *Reader) Read(p []byte) (n int, err error) {

// If the frame preceding EOF provided a fragment URL, open it directly.
if !r.Request.MetadataOnly && r.Response.Status == pb.Status_OK && r.Response.FragmentUrl != "" {
if SkipSignedURLs > 0 {
if SkipSignedURLs {
fragURL := r.Response.Fragment.BackingStore.URL()
if fragURL.Scheme != "gs" {
return 0, fmt.Errorf("SkipSignedURL unsupported scheme: %s", fragURL.Scheme)
Expand Down Expand Up @@ -484,7 +484,7 @@ var (
// stores_test.go, which is in broker/fragment, imports broker/client so we cannot import broker/fragment here
// to avoid a cycle. Instead we will repeat a subset of store_gcs.go.

var SkipSignedURLs = uint32(0)
var SkipSignedURLs = false
var gcs = &gcsBackend{}

type gcsBackend struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazette/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (cmdServe) Execute(args []string) error {
}

func main() {
var parser = flags.NewParser(Config, flags.Default)
var parser = flags.NewParser(Config, flags.Default|flags.AllowBoolValues)

_, _ = parser.AddCommand("serve", "Serve as Gazette broker", `
Serve a Gazette broker with the provided configuration, until signaled to
Expand Down
4 changes: 2 additions & 2 deletions mainboilerplate/runconsumer/run_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type BaseConfig struct {
Limit uint32 `long:"limit" env:"LIMIT" default:"32" description:"Maximum number of Shards this consumer process will allocate"`
MaxHotStandbys uint32 `long:"max-hot-standbys" env:"MAX_HOT_STANDBYS" default:"3" description:"Maximum effective hot standbys of any one shard, which upper-bounds its stated hot-standbys."`
WatchDelay time.Duration `long:"watch-delay" env:"WATCH_DELAY" default:"30ms" description:"Delay applied to the application of watched Etcd events. Larger values amortize the processing of fast-changing Etcd keys."`
SkipSignedURLs uint32 `long:"skip-signed-urls" env:"SKIP_SIGNED_URLS" default:"0" description:"When a signed URL is received, use fragment info instead to retrieve data with auth header. This is useful when clients do not wish/require the signing."`
SkipSignedURLs bool `long:"skip-signed-urls" env:"SKIP_SIGNED_URLS" default:"false" description:"When a signed URL is received, use fragment info instead to retrieve data with auth header. This is useful when clients do not wish/require the signing."`
} `group:"Consumer" namespace:"consumer" env-namespace:"CONSUMER"`

Broker struct {
Expand Down Expand Up @@ -204,7 +204,7 @@ func (sc Cmd) Execute(args []string) error {
func Main(app Application) {
var cfg = app.NewConfig()

var parser = flags.NewParser(cfg, flags.Default)
var parser = flags.NewParser(cfg, flags.Default|flags.AllowBoolValues)
log.Info("Starting consumer...")
_, _ = parser.AddCommand("serve", "Serve as Gazette consumer", `
serve a Gazette consumer with the provided configuration, until signaled to
Expand Down

0 comments on commit b136b0f

Please sign in to comment.