sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Perhaps Send should break apart protocol error from result.

Open n3wscott opened this issue 4 years ago • 2 comments

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

n3wscott avatar Jun 25 '20 19:06 n3wscott

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

slinkydeveloper avatar Jun 26 '20 06:06 slinkydeveloper

I wonder that is v3 represents the cloud sdk-go version 3?

abserari avatar Jul 01 '20 02:07 abserari