Skip to content

Commit

Permalink
reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Norton committed Jan 1, 2024
1 parent 8eb32c2 commit 6261a80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions policy/goals/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type (
ImageDigest string `edn:"docker.image/digest"`
ImagePlatforms []ImagePlatform `edn:"docker.image/platform" json:"platforms"`
}
)

type GoalEvaluator interface {
EvaluateGoal(ctx context.Context, req skill.RequestContext, commonData CommonSubscriptionQueryResult, subscriptionResults [][]edn.RawMessage) ([]GoalEvaluationQueryResult, error)
}
GoalEvaluator interface {
EvaluateGoal(ctx context.Context, req skill.RequestContext, commonData CommonSubscriptionQueryResult, subscriptionResults [][]edn.RawMessage) ([]GoalEvaluationQueryResult, error)
}
)
9 changes: 5 additions & 4 deletions policy/policy_handler/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ import (
"context"
b64 "encoding/base64"
"fmt"

"github.com/atomist-skills/go-skill"
"github.com/atomist-skills/go-skill/policy/data"
"olympos.io/encoding/edn"
)

const EventNameAsyncQuery = data.AsyncQueryName // these must match for the event handler to be registered
const eventNameAsyncQuery = data.AsyncQueryName // these must match for the event handler to be registered

// WithAsync will enable async graphql queries for the EventHandler.
// When used, data.QueryResponse#AsyncRequestMade will be true when performed asynchronously.
// If that flag is set, the policy evaluator should terminate early with no results.
// It will be automatically retried once the async query results are returned.
func WithAsync() Opt {
return func(h *EventHandler) {
h.subscriptionNames = append(h.subscriptionNames, EventNameAsyncQuery)
h.subscriptionNames = append(h.subscriptionNames, eventNameAsyncQuery)
h.subscriptionDataProviders = append(h.subscriptionDataProviders, getAsyncSubscriptionData)
h.dataSourceProviders = append(h.dataSourceProviders, buildAsyncDataSources)
}
}

func getAsyncSubscriptionData(ctx context.Context, req skill.RequestContext) ([][]edn.RawMessage, skill.Configuration, error) {
if req.Event.Context.AsyncQueryResult.Name != EventNameAsyncQuery {
if req.Event.Context.AsyncQueryResult.Name != eventNameAsyncQuery {
return nil, skill.Configuration{}, nil
}

Expand All @@ -50,7 +51,7 @@ func buildAsyncDataSources(ctx context.Context, req skill.RequestContext) ([]dat
return []data.DataSource{}, nil
}

if req.Event.Context.AsyncQueryResult.Name != EventNameAsyncQuery {
if req.Event.Context.AsyncQueryResult.Name != eventNameAsyncQuery {
return []data.DataSource{
data.NewAsyncDataSource(req, req.Event.Context.Subscription.Result, map[string]data.AsyncQueryResponse{}),
}, nil
Expand Down

0 comments on commit 6261a80

Please sign in to comment.