Skip to content

Commit

Permalink
use config flag in place of environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ddowker committed May 23, 2024
1 parent 57846ad commit 21558eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions broker/fragment/store_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"net/url"
"os"
"strings"
"sync"
"time"
Expand All @@ -28,8 +27,6 @@ type GSStoreConfig struct {
RewriterConfig
}

var gcs_do_not_sign_urls = os.Getenv("GCS_DO_NOT_SIGN_URLS")

type gcsBackend struct {
client *storage.Client
signedURLOptions storage.SignedURLOptions
Expand All @@ -46,7 +43,7 @@ func (s *gcsBackend) SignGet(ep *url.URL, fragment pb.Fragment, d time.Duration)
return "", err
}

if gcs_do_not_sign_urls == "true" {
if SignedUrlsOff {
u := &url.URL{
Path: fmt.Sprintf("/%s/%s", cfg.bucket, cfg.rewritePath(cfg.prefix, fragment.ContentPath())),
}
Expand Down
3 changes: 3 additions & 0 deletions broker/fragment/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
// If true, fragments are not persisted, and stores are not listed for existing fragments.
var DisableStores bool = false

// Whether to return an unsigned URL when a signed URL is requested. Useful when clients do not require the signing.
var SignedUrlsOff bool = false

type backend interface {
Provider() string
SignGet(ep *url.URL, fragment pb.Fragment, d time.Duration) (string, error)
Expand Down
2 changes: 2 additions & 0 deletions cmd/gazette/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var Config = new(struct {
MinAppendRate uint32 `long:"min-append-rate" env:"MIN_APPEND_RATE" default:"65536" description:"Min rate (in bytes-per-sec) at which a client may stream Append RPC content. RPCs unable to sustain this rate are aborted"`
DisableStores bool `long:"disable-stores" env:"DISABLE_STORES" description:"Disable use of any configured journal fragment stores. The broker will neither list or persist remote fragments, and all data is discarded on broker exit."`
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."`
SignedUrlsOff bool `long:"signed-urls-off" env:"SIGNED_URLS_OFF" description:"When a signed URL is requested, return an unsigned URL instead. This is useful when clients do not require the signing."`
} `group:"Broker" namespace:"broker" env-namespace:"BROKER"`

Etcd struct {
Expand Down Expand Up @@ -71,6 +72,7 @@ func (cmdServe) Execute(args []string) error {
broker.MaxAppendRate = int64(Config.Broker.MaxAppendRate)
pb.MaxReplication = int32(Config.Broker.MaxReplication)
fragment.DisableStores = Config.Broker.DisableStores
fragment.SignedUrlsOff = Config.Broker.SignedUrlsOff

var (
lo = pb.NewJournalClient(srv.GRPCLoopback)
Expand Down

0 comments on commit 21558eb

Please sign in to comment.