Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Error Execution Utilities: Add Retry, Timeout, Cancellation, and Advanced Error Handling #130

Open
UTSAVS26 opened this issue Mar 7, 2025 · 4 comments · May be fixed by #153
Open

Comments

@UTSAVS26
Copy link

UTSAVS26 commented Mar 7, 2025

File: utils/error.go


Problem

Right now, the error execution utilities (ErrExec, ErrExecSequential) work fine, but they’re missing some important features that would make them way more useful in real-world applications. Specifically, they don't support:

  1. Timeout and cancellation: The ability to cancel or timeout functions, especially when running multiple functions at the same time.
  2. Retry Logic: If a function fails, we can’t retry it automatically before giving up.
  3. Better Error Handling: We need a more flexible way to handle errors, like being able to wrap errors, accumulate multiple errors, or stop execution when certain types of errors happen.

Without these features, it’s harder to handle failures, especially in complex systems or processes that involve retries, cancellations, or need better error tracking.


Solution

To improve the current utilities, we could add the following features:

  1. Timeout and Cancellation Support: Modify the existing concurrent execution function to allow cancelling or timing out tasks, so that if something goes wrong or takes too long, we can stop it early.

  2. Retry Logic: Add a way to automatically retry failed functions a certain number of times, with some time in between, before giving up on them. This is super useful when dealing with temporary failures like network issues.

  3. Better Error Handling: Improve the sequential execution function to allow more flexible error handling, like stopping early if a critical error occurs, or limiting how many errors we accumulate before quitting.

  4. Consistent Function Signatures: Make sure all the functions have a similar structure and return types, so they're easier to use together in larger projects.

  5. Optional Logging or Metrics: Add optional features for logging or tracking metrics, so we can monitor how these functions are performing and debug issues more easily.

These updates will make the utilities way more robust and easier to work with, especially in production systems where reliability is key.

@UTSAVS26
Copy link
Author

UTSAVS26 commented Mar 9, 2025

@zriyanshdz Can you please look into this issue?

@shubham19may
Copy link
Contributor

@UTSAVS26 have you run/tested the code and made the analysis based on the code structure?
If yes, please point out exact instances where you think these will be used? or may be create a PR so we can implement it similarly.

We would really appreciate if you can start contribution with the same.

@UTSAVS26
Copy link
Author

Hello @shubham19may ,

Yeah, I’ve gone through the current code, and I see where the new features could fit in. Here’s where I think these updates would be useful:

  1. Timeout and Cancellation: This would help in cases where a task is taking too long, like network calls or long-running processes. If it takes too long, we can cancel it to avoid hanging indefinitely.

  2. Retry Logic: If a function fails temporarily (like due to a network issue), retrying it a few times before giving up could be really helpful, especially for things like API calls or I/O operations.

  3. Better Error Handling: Right now, we just return errors as they come, but we could improve it by handling multiple errors and deciding when to stop (for example, if a critical error happens or we hit a certain number of failures).

Let me know how you'd like to go about it!

@UTSAVS26
Copy link
Author

@shubham19may I have raised PR for this issue #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants