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

async query is not no data #37

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion policy/goals/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ type (
}

GoalEvaluator interface {
EvaluateGoal(ctx context.Context, req skill.RequestContext, commonData CommonSubscriptionQueryResult, subscriptionResults [][]edn.RawMessage) ([]GoalEvaluationQueryResult, error)
EvaluateGoal(ctx context.Context, req skill.RequestContext, commonData CommonSubscriptionQueryResult, subscriptionResults [][]edn.RawMessage) (EvaluationResult, error)
}

EvaluationResult struct {
EvaluationCompleted bool
Result []GoalEvaluationQueryResult
}
)
9 changes: 8 additions & 1 deletion policy/policy_handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ func (h EventHandler) evaluate(ctx context.Context, req skill.RequestContext, da
req.Log.Infof("Evaluating goal %s for digest %s ", goalName, digest)
evaluationTs := time.Now().UTC()

goalResults, err := evaluator.EvaluateGoal(ctx, req, commonResults, subscriptionResult)
evaluationResult, err := evaluator.EvaluateGoal(ctx, req, commonResults, subscriptionResult)
if err != nil {
req.Log.Errorf("Failed to evaluate goal %s for digest %s: %s", goal.Definition, digest, err.Error())
return skill.NewFailedStatus("Failed to evaluate goal")
}

if !evaluationResult.EvaluationCompleted {
req.Log.Info("evaluation incomplete")
return skill.NewCompletedStatus("Evaluation incomplete")
}

goalResults := evaluationResult.Result

for _, f := range h.transactFilters {
if !f(ctx, req) {
// if not transacting, we return results as part of the skill result
Expand Down