Skip to content

Commit

Permalink
Add --link-expires for gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Feb 11, 2025
1 parent 0e75fad commit a15c653
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/crproxy/cluster/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func runE(ctx context.Context, flags *flagpole) error {
cache.WithSignLink(flags.SignLink),
cache.WithStorageDriver(sd),
)
if flags.LinkExpires > 0 {
bigCacheOpts = append(bigCacheOpts, cache.WithLinkExpires(flags.LinkExpires))
}
bigsdcache, err := cache.NewCache(bigCacheOpts...)
if err != nil {
return fmt.Errorf("create cache failed: %w", err)
Expand Down
9 changes: 9 additions & 0 deletions cmd/crproxy/cluster/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type flagpole struct {

StorageURL string
RedirectLinks string
LinkExpires time.Duration
SignLink bool

ManifestCacheDuration time.Duration
Expand Down Expand Up @@ -89,6 +90,7 @@ func NewCommand() *cobra.Command {
cmd.Flags().StringVar(&flags.BigStorageURL, "big-storage-url", flags.BigStorageURL, "Big storage driver url")
cmd.Flags().IntVar(&flags.BigStorageSize, "big-storage-size", flags.BigStorageSize, "Big storage size")
cmd.Flags().StringVar(&flags.RedirectLinks, "redirect-links", flags.RedirectLinks, "Redirect links")
cmd.Flags().DurationVar(&flags.LinkExpires, "link-expires", flags.LinkExpires, "Link expires")
cmd.Flags().BoolVar(&flags.SignLink, "sign-link", flags.SignLink, "Sign Link")

cmd.Flags().DurationVar(&flags.ManifestCacheDuration, "manifest-cache-duration", flags.ManifestCacheDuration, "Manifest cache duration")
Expand Down Expand Up @@ -173,6 +175,10 @@ func runE(ctx context.Context, flags *flagpole) error {
}
cacheOpts = append(cacheOpts, cache.WithStorageDriver(sd))

if flags.LinkExpires > 0 {
cacheOpts = append(cacheOpts, cache.WithLinkExpires(flags.LinkExpires))
}

if flags.RedirectLinks != "" {
u, err := url.Parse(flags.RedirectLinks)
if err != nil {
Expand Down Expand Up @@ -205,6 +211,9 @@ func runE(ctx context.Context, flags *flagpole) error {
cache.WithSignLink(flags.SignLink),
cache.WithStorageDriver(sd),
)
if flags.LinkExpires > 0 {
bigCacheOpts = append(bigCacheOpts, cache.WithLinkExpires(flags.LinkExpires))
}
bigsdcache, err := cache.NewCache(bigCacheOpts...)
if err != nil {
return fmt.Errorf("create cache failed: %w", err)
Expand Down

0 comments on commit a15c653

Please sign in to comment.