knative-extensions / kn-plugin-event

Kn plugin for sending events to Knative sinks.
Apache License 2.0
7 stars 22 forks source link

Show optional response event when sending an event #383

Open rhuss opened 3 days ago

rhuss commented 3 days ago

It would be great to show the HTTP response when a CE has been sent when testing microservices that consume and produce Cloud Events as response.

Currently, the response is just ignored. The Golang CE SDK supports a more sophisticated way to send events that also allows the inspection of the response via https://github.com/cloudevents/sdk-go/blob/de2f28370b0d2a0f64f92c0c6139fa4b8a7c3851/v2/protocol/http/protocol.go#L178

Not sure how to get this from the in-cluster sender image to the CLI (except to log to stdout), but for the out-cluster sending from the CLI this should be not too difficult.

cardil commented 3 days ago

/triage accepted /kind enhancement

I think this can be done, and could be handy, especially for things like Quarkus Funqy runtime for Func, which has a response type by default.

cardil commented 3 days ago

However, I think we should stick to CE events, and present the response only if a valid CE is returned (not for a general HTTP response). WDYT @rhuss?

rhuss commented 3 days ago

I'm okay with that. You can always add the complete response in the --verbose output, even when its not a CE. When restricting for CE you could reuse the way how gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display renders the event in its log

cardil commented 2 days ago

Sure, the rendering is already implemented in kn-event. Dumping the raw HTTP in debug logs is also good idea.