Skip to content

Commit

Permalink
Merge pull request #21 from raj-prince/enable-stall-retry
Browse files Browse the repository at this point in the history
feat: adding support of read-stall-retry
  • Loading branch information
raj-prince authored Nov 2, 2024
2 parents 2ac0731 + 5fac916 commit 5716613
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io"
"log"
"net/http"

// Register the pprof endpoints under the web server root at /debug/pprof
_ "net/http/pprof"
"os"
Expand All @@ -21,6 +20,7 @@ import (

"cloud.google.com/go/profiler"
"cloud.google.com/go/storage"
"cloud.google.com/go/storage/experimental"
"github.com/googleapis/gax-go/v2"
"go.opencensus.io/stats"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -68,6 +68,9 @@ var (
projectID = flag.String("project_id", "", "project ID to run profiler with; only required when running outside of GCP.")
version = flag.String("version", "original", "version to run profiler with")

// Enable read stall retry.
enableReadStallRetry = flag.Bool("enable-read-stall-retry", false, "Enable read stall retry")

eG errgroup.Group
)

Expand Down Expand Up @@ -113,7 +116,15 @@ func CreateHTTPClient(ctx context.Context, isHTTP2 bool) (client *storage.Client
UserAgent: "prince",
}

return storage.NewClient(ctx, option.WithHTTPClient(httpClient))
if *enableReadStallRetry {
return storage.NewClient(ctx, option.WithHTTPClient(httpClient),
experimental.WithReadStallTimeout(&experimental.ReadStallTimeoutConfig{
Min: time.Second,
TargetPercentile: 0.99,
}))
} else {

Check failure on line 125 in main.go

View workflow job for this annotation

GitHub Actions / audit

if block ends with a return statement, so drop this else and outdent its block
return storage.NewClient(ctx, option.WithHTTPClient(httpClient))
}
}

// CreateGrpcClient creates grpc client.
Expand Down

0 comments on commit 5716613

Please sign in to comment.