sdk-go
sdk-go copied to clipboard
IsUndelivered() returns false even when event was not delivered
I just adapted the sender and receiver examples from the main repo page a little bit and when the receiver isn't running but I run the sender then IsUndelivered()
returns false
even though the event was not delivered.
event := cloudevents.NewEvent()
event.SetSource("example.com/test")
event.SetType("example.type")
event.SetData(cloudevents.ApplicationJSON, data)
ctx := cloudevents.ContextWithTarget(context.Background(), "http://127.0.0.1:8080/")
result := c.Send(ctx, event)
log.Printf("IsUndelivered(result): %+v\n", cloudevents.IsUndelivered(result))
if cloudevents.IsUndelivered(result) {
log.Fatalf("undelivered: %+v\n", result)
}
fmt.Printf("delivered: %+v\n", result)
results in:
delivered: Post "http://127.0.0.1:8080/": dial tcp 127.0.0.1:8080: connect: connection refused
2022/10/27 22:06:37 IsUndelivered(result): false
IsUndelivered() should clearly return true in this case.