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

test v0 preconditions in parallel #343

Merged
merged 1 commit into from Dec 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 22 additions & 7 deletions internal/services/v0/acl.go
Expand Up @@ -11,6 +11,7 @@ import (
grpcmw "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/rs/zerolog/log"
"github.com/shopspring/decimal"
"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -255,13 +256,27 @@ func (as *aclServer) commonCheck(
start *v0.ObjectAndRelation,
goal *v0.ObjectAndRelation,
) (*v0.CheckResponse, error) {
err := as.nsm.CheckNamespaceAndRelation(ctx, start.Namespace, start.Relation, false, atRevision)
if err != nil {
return nil, rewriteACLError(ctx, err)
}

err = as.nsm.CheckNamespaceAndRelation(ctx, goal.Namespace, goal.Relation, true, atRevision)
if err != nil {
// Perform our preflight checks in parallel
errG, checksCtx := errgroup.WithContext(ctx)
errG.Go(func() error {
return as.nsm.CheckNamespaceAndRelation(
checksCtx,
start.Namespace,
start.Relation,
false,
atRevision,
)
})
errG.Go(func() error {
return as.nsm.CheckNamespaceAndRelation(
checksCtx,
goal.Namespace,
goal.Relation,
true,
atRevision,
)
})
if err := errG.Wait(); err != nil {
return nil, rewriteACLError(ctx, err)
}

Expand Down