openfaas / connector-sdk

SDK for connecting events to functions
MIT License
54 stars 25 forks source link

BeginMapBuilder() should return an error #19

Closed embano1 closed 4 years ago

embano1 commented 5 years ago

Right now, when using the connector SDK and the connector client cannot connect/reach OpenFaaS gateway, it fails with a not very user friendly log.Fatal error:

2019/02/18 22:16:44 Get http://127.0.0.1:8080/system/functions: dial tcp 127.0.0.1:8080: connect: connection refused

In larger and more complex programs using the SDK this can get tricky to debug.

Instead, it should return an error (or <-chan error since it's spawning a goroutine) so users of the SDK can handle the error appropriately (retry, wrap the error, use different logging [related #6 ]).

alexellis commented 4 years ago

this sounds like a very reasonable request to improve the connector sdk.

embano1 commented 4 years ago

+1 However, I closed this issue since BeginMapBuilder() spawns a goroutine [1], which currently calls log.Fatal() for any error returned. According to #44 this is encouraged until we come up with a general approach of error propagation in the SDK.

[1] https://github.com/openfaas-incubator/connector-sdk/blob/b997b460ed7280d941b8500feb96c7434ee4e271/types/controller.go#L148