Is there any way to attach some kind of listener t...
# prefect-community
j
Is there any way to attach some kind of listener to a flow as it changes states? In Prefect 1 I would have done this with state handlers, but those don’t seem to be an option if I’m looking to monitor the flow status instead of task status. My use case is to sync the Flow status with our legacy (homegrown) orchestrator to help perform the migration, so it can almost be thought of as custom notifications.
1
c
Hi Josh, it seems like this is what you’re asking about ? https://docs.prefect.io/ui/notifications/
j
Notifications only support Slack and Email, but this involves (at minimum) running some custom code to invoke a lambda. If I could write my own notification type then that would do the trick.
n
If I could write my own notification type then that would do the trick.
You can (if you're running your own orion instance) in a similar way to how we've written the
SlackWebhook
block here, you're free to subclass NotificationBlock and register that block type to your workspace docs on creating new block types
j
Ooh that would probably do the trick. Let me give it a try. Thanks!
Maybe I’m missing something here, but which part of the Notifications block is actually listening to the state change to call that
notify
method?
a
There is a service that runs server side that is responsible for invoking the
notify
method on a notification block for the appropriate state changes. The notification block needs to be available server side for sending notifications, so custom notification blocks require you to run your own Orion server. We’re working on supporting more notification types in Prefect Cloud.
j
Ahh. Then in that case it seems like it won’t work for me since I’m using Cloud 😞