fix(eda): the undispatched-capture batch lists only captures an enabled binding still owes
Issue: archie-core-kfjz1
This commit is contained in:
1 parent
df20b64f62
commit
cf5674f5da
10 files changed
+49
-37
No files matched your search
@@ -598,9 +598,9 @@ func (d *Daemon) dispatchBindings(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (d *Daemon) dispatchOrgBindings(ctx context.Context) {
|
||||
// Gather the sources of armed bindings whose workflow is enabled first, so
|
||||
// the oldest-first captures query is not held by captures that wait on a
|
||||
// disabled workflow.
|
||||
// Gather the armed bindings whose workflow is enabled first, so the
|
||||
// oldest-first captures query is not held by captures that only a binding
|
||||
// on a disabled workflow would take.
|
||||
bindings, err := d.Bindings.ListBindings(ctx)
|
||||
if err != nil {
|
||||
d.Log.Warn("list bindings failed", "error", err)
|
||||
@@ -611,17 +611,17 @@ func (d *Daemon) dispatchOrgBindings(ctx context.Context) {
|
||||
d.Log.Warn("binding dispatch: workflow enablement unavailable", "error", err)
|
||||
return
|
||||
}
|
||||
sources := make([]string, 0, len(bindings))
|
||||
enabled := make([]string, 0, len(bindings))
|
||||
for _, b := range bindings {
|
||||
if b.OrgID == org.OrgFromContext(ctx) && b.Status == binding.StatusArmed && b.Matcher.Source != "" && enablement.Enabled(b.OrgID, b.Workflow) {
|
||||
sources = append(sources, b.Matcher.Source)
|
||||
enabled = append(enabled, b.ID)
|
||||
}
|
||||
}
|
||||
if len(sources) == 0 {
|
||||
if len(enabled) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
captures, err := d.BindingDispatcher.ListUndispatchedCaptures(ctx, sources, bindingDispatchBatchLimit)
|
||||
captures, err := d.BindingDispatcher.ListUndispatchedCaptures(ctx, enabled, bindingDispatchBatchLimit)
|
||||
if err != nil {
|
||||
d.Log.Warn("list undispatched captures failed", "error", err)
|
||||
return
|
||||
|
||||
@@ -46,10 +46,12 @@ func (s *orgBindingStore) ArmedBindingsForSource(_ context.Context, source strin
|
||||
return slices.DeleteFunc(slices.Clone(s.bindings), func(b binding.Binding) bool { return b.Matcher.Source != source }), nil
|
||||
}
|
||||
|
||||
func (*orgBindingStore) ListUndispatchedCaptures(_ context.Context, sources []string, _ int) ([]storecontract.CapturedEvent, error) {
|
||||
func (s *orgBindingStore) ListUndispatchedCaptures(_ context.Context, bindings []string, _ int) ([]storecontract.CapturedEvent, error) {
|
||||
var captures []storecontract.CapturedEvent
|
||||
for _, source := range sources {
|
||||
captures = append(captures, storecontract.CapturedEvent{ID: source, Source: source, EventType: source, Body: "{}", Authenticated: true})
|
||||
for _, b := range s.bindings {
|
||||
if slices.Contains(bindings, b.ID) {
|
||||
captures = append(captures, storecontract.CapturedEvent{ID: b.Matcher.Source, Source: b.Matcher.Source, EventType: b.Matcher.Source, Body: "{}", Authenticated: true})
|
||||
}
|
||||
}
|
||||
return captures, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user