From 47bdd2d396f12f1689cf9e6dc6f5f2fc336f1fd6 Mon Sep 17 00:00:00 2001 From: hperl <34397+hperl@users.noreply.github.com> Date: Mon, 30 May 2022 16:55:03 +0200 Subject: [PATCH] fix: listen to results directly --- internal/check/engine.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/check/engine.go b/internal/check/engine.go index fd86338aa..72fe21e14 100644 --- a/internal/check/engine.go +++ b/internal/check/engine.go @@ -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 {