sdk-go
sdk-go copied to clipboard
Perhaps Send should break apart protocol error from result.
Perhaps the API would have been simpler if we returned (Receipt, error) and broken out the 3. case into a distinct thing, and then Receipt could be nil in that case.
+1 I would even argue that Result, Receipt and error are distinct things.
Originally posted by @deissnerk in https://github.com/cloudevents/sdk-go/issues/526#issuecomment-649626412
IMO it's not that bad to have these wrapped all in the same error, what we miss are helpers to use them and unwrap them. For example: it would be cool to have an helper that unwraps a [protocol x] result from the initial result, like
if result := c.Send(context.Background(), event); cloudevents.Undelivered(result) {
log.Fatalf("Failed to send: %v", result)
} else if httpRes := cehttp.GetHttpResult(result); httpRes != nil {
log.Printf("Http result: %v", httpRes)
}
What I propose is: let's try to make the usage simpler with such methods, if that doesn't work out I'm fully ok to drop that concept in v3
I wonder that is v3 represents the cloud sdk-go version 3?