qri-io / qri

you're invited to a data party!
https://qri.io
GNU General Public License v3.0
1.11k stars 66 forks source link

feat(trigger): `Trigger`, `Listener`, and `Source` interfaces, as well as `AssertTriggerListener` spec tests #1814

Closed ramfox closed 3 years ago

ramfox commented 3 years ago

closes #1792

ramfox commented 3 years ago

@b5 last convo we had about the listeners keeping internal stores of active triggers, we decided to add listener.UpdateTriggers(source Source) error to the trigger.Listener interface. Looking through your june demo spike surrounding the CronTrigger, I see a CronListener.Listen(source ...Source) method.

What do you think about removing UpdateTriggers in favor of Listen, with the expectation that Listen is called, providing a list of active sources when the Listener is mounted, and Listen is called whenever a workflow is created or updated (the way UpdateTriggers is used now).

b5 commented 3 years ago

yep, I think renaming UpdateTriggers to Listen & making the argument variadic are both wins. Repeated calls to listen makes sense to me