-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add service for event and integration with Prefect event #4493
Conversation
branch=context.branch.name, | ||
kind=obj._schema.kind, | ||
namespace=obj._schema.namespace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might have a bit limiting previously to only have kind
but I think the addition of namespace here gets a bit weird if we keep kind. We should either just leave it as "kind" or remove kind if we have "name" and "namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it for now, we can revisit that later but having just the kind is not enough in my perspective if we need to do some filtering
resource=event.get_resource(), | ||
related=event.get_related(), | ||
payload=event.get_payload(), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit problematic, is there an async version of emit_event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I could find quickly but as far as I understand they are sending the event in a non blocking way. I'm planning to dive deeper into it soon.
We may have to create our own function to send the event but for now since we are sending the events in a background task I don't think it will make a big different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right the background tasks are run in a separate thread regardless. But we'll have to keep it in mind if used elsewhere, though if Prefects emit_event does the same it should be fine.
661d40f
to
814987f
Compare
814987f
to
d4417f4
Compare
Initial integration of Infrahub events with prefect event
To avoid having to define/send event twice, I've introduced a new
event
service that will automatically send event to the message bus and to prefect.This PR also introduces a new
InfrahubEvent
dataclass which support both formats: internal bus and prefectFor now I've only implemented the node mutated event for testing.
I'm still exploring how events are working in prefect and what is the best way to integrate with them.
in prefect an event must have be associated with a resource and can have multiple related resources.
Both resource and related resources are defined as a dictionary of key: value pair with the following constraints
prefect.resource.id
prefect.resource.id
andprefect.resource.role
below is the payload of the event generated after creating a new node in prefect