Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MakeVersionRequestsWithContext() #781

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/depsdev/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ func VersionQuery(system depsdevpb.System, name string, version string) *depsdev
}
}

// MakeVersionRequests calls the deps.dev GetVersion gRPC API endpoint for each
// MakeVersionRequests wraps MakeVersionRequestsWithContext using context.Background.
func MakeVersionRequests(queries []*depsdevpb.GetVersionRequest) ([][]models.License, error) {
return MakeVersionRequestsWithContext(context.Background(), queries)
}

// MakeVersionRequestsWithContext calls the deps.dev GetVersion gRPC API endpoint for each
// query. It makes these requests concurrently, sharing the single HTTP/2
// connection. The order in which the requests are specified should correspond
// to the order of licenses returned by this function.
func MakeVersionRequests(queries []*depsdevpb.GetVersionRequest) ([][]models.License, error) {
ctx := context.TODO()
func MakeVersionRequestsWithContext(ctx context.Context, queries []*depsdevpb.GetVersionRequest) ([][]models.License, error) {
certPool, err := x509.SystemCertPool()
if err != nil {
return nil, fmt.Errorf("getting system cert pool: %w", err)
Expand All @@ -63,7 +67,7 @@ func MakeVersionRequests(queries []*depsdevpb.GetVersionRequest) ([][]models.Lic
client := depsdevpb.NewInsightsClient(conn)

licenses := make([][]models.License, len(queries))
var g errgroup.Group
g, ctx := errgroup.WithContext(ctx)
for i := range queries {
if queries[i] == nil {
// This may be a private package.
Expand Down
Loading