Hi,
I am working with Google Cloud Run and using Funqy with Knative events and ran into a limitation (mainly due to simplified use of cloud events from Cloud Run in my opinion).
When using cloud run you can configure different triggers (but you can’t create custom ones - like custom in terms you define what is the value of the type attribute) and in my case it’s the PubSub trigger. The problem here is that Cloud Run will use the same value for type attribute (google.cloud.pubsub.topic.v1.messagePublished) regardless of the topic it comes from. The topic itself is given as source attribute of the cloud event. On the other side Funqy with cloud events uses only type attribute of the cloud event as the trigger correlation so to say. That means it’s going to trigger all functions as they will use the same type defined via @CloudEventMapping.
See this docs page describing how the cloud event are used in Cloud Run
Proposal
I was thinking to provide an optional attribute on the @CloudEventMapping annotation that allows to define the filter on source attribute.
@CloudEventMapping(trigger = "google.cloud.pubsub.topic.v1.messagePublished”, filter=“//pubsub.googleapis.com/projects/my-project/topics/orders”)
@CloudEventMapping(trigger = "google.cloud.pubsub.topic.v1.messagePublished”, filterAttribute=“custom-header” filterValue=“custom value”)
With this we could easily use Funqy with cloud events on Cloud Run and I believe this could be useful even outside of the Cloud Run context to allow to filter based on at least the source of the cloud event.
Thoughts?
Thanks
Maciej