Closed sandangel closed 1 year ago
If the request is just for cobra.Command
, use Run
instead of RunE
, which does not need to return an error.
The Start
function in the SDK is intended to be the top level - it is used to start a gRPC server, it does not need to have an upper level to manage it - imagine with a gRPC server start error thrown to upper level, what you can do other than printing the log and letting the container panic? The SDK is intended to simplify the UDF implementation, returning an error means the SDK users have to deal with the error.
@whynowy I still think it's better to let the user handle the error by themselves. They can ignore it if not care. But more robust applications have different ways of handling errors, like sending notifications and tracking errors in Sentry. If the sdk log.Fatalf then the app won't be able to handle such logic.
Another case is where the user want to abstract numaflow away from the application code. They might be using multiple orchestration tool and only some functions will be handled by numaflow. They would create an interface and wrap around the numaflow-sdk. Not returning error won't let them handle the errors nicely
If you think it's better to not have user handling the error, I can create a separated function, like StartE
and that one will return error. Does it sound good?
Makes sense, thanks!
In golang app, usually we handle the error at top level command. Sub function calls just return the error to the upper function for it to decide what to do with the error.
Can Numaflow UDF grpc server start method return the error instead of calling log.FatalF for error handling?
Example usage with Cobra