Skip to content

Commit

Permalink
Review Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Dec 6, 2023
1 parent d83cecf commit 4ee92d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
10 changes: 0 additions & 10 deletions azure/azblob/azblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,6 @@ func (c *Client) DeleteBlob(ctx context.Context, uri string) error {
return nil
}

func (c *Client) DeleteBlobs(ctx context.Context, uris []string) error {
// Implement parallel delete if slow - not prematurely optimizing.
for i, uri := range uris {
if err := c.DeleteBlob(ctx, uri); err != nil {
return fmt.Errorf("deleting blob %d/%d: %w", i, len(uris), err)
}
}
return nil
}

// SignedUploadURL returns a URL that is allowed to upload to the given URI.
// See https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/storage/[email protected]/sas#example-package-UserDelegationSAS
func (c *Client) SignedUploadURL(ctx context.Context, uri string) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions cmd/server/pactasrv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
"initiative_user_relationship.go",
"pacta_version.go",
"pactasrv.go",
"parallel.go",
"portfolio.go",
"upload.go",
"user.go",
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/pactasrv/pactasrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type Blob interface {
SignedUploadURL(ctx context.Context, uri string) (string, error)
// For downloading reports
SignedDownloadURL(ctx context.Context, uri string) (string, error)
DeleteBlobs(ctx context.Context, uris []string) error
DeleteBlob(ctx context.Context, uri string) error
}

type Server struct {
Expand Down
24 changes: 24 additions & 0 deletions cmd/server/pactasrv/parallel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pactasrv

import (
"context"
"fmt"
)

type blobDeleter interface {
DeleteBlob(ctx context.Context, uri string) error
}

func deleteBlobs(ctx context.Context, bd blobDeleter, uris []string) error {
// Implement parallel delete if slow - not prematurely optimizing.
for i, uri := range uris {
if err := bd.DeleteBlob(ctx, uri); err != nil {
return fmt.Errorf("deleting blob %d/%d: %w", i, len(uris), err)
}
}
return nil
}

func (s *Server) deleteBlobs(ctx context.Context, uris []string) error {
return deleteBlobs(ctx, s.Blob, uris)
}

0 comments on commit 4ee92d0

Please sign in to comment.