Skip to content

Commit

Permalink
fix: listen to results directly
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed May 30, 2022
1 parent 28d8158 commit 47bdd2d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/check/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,16 @@ func (e *Engine) SubjectIsAllowed(ctx context.Context, r *RelationTuple, restDep
if globalMaxDepth := e.d.Config(ctx).MaxReadDepth(); restDepth <= 0 || globalMaxDepth < restDepth {
restDepth = globalMaxDepth
}
result := or(ctx, []checkgroup.Func{e.checkIsAllowed(ctx, r, restDepth)})

return result.Membership == checkgroup.IsMember, result.Err
resultCh := make(chan checkgroup.Result)
go e.checkIsAllowed(ctx, r, restDepth)(ctx, resultCh)
select {
case result := <-resultCh:
return result.Membership == checkgroup.IsMember, result.Err
case <-ctx.Done():
return false, context.Canceled
}

}

func (e *Engine) checkIsAllowed(ctx context.Context, r *RelationTuple, restDepth int) checkgroup.Func {
Expand Down

0 comments on commit 47bdd2d

Please sign in to comment.