WangYihang / gojob

Go(od) Job is a simple job scheduler that supports task retries, logging, and task sharding.
MIT License
10 stars 1 forks source link

add missing defer close for RunWithTimeout #7

Closed emar-kar closed 5 months ago

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 24.77%. Comparing base (e279609) to head (cbc8dc6).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #7 +/- ## ========================================== + Coverage 24.68% 24.77% +0.09% ========================================== Files 26 26 Lines 786 787 +1 ========================================== + Hits 194 195 +1 Misses 575 575 Partials 17 17 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

WangYihang commented 5 months ago

@emar-kar Any suggestions? Feel free to correct me if I am wrong, thanks a lot!

emar-kar commented 5 months ago

@WangYihang as far as I know, when you use make it always allocates memory on the heap. As soon as channel escapes the function, I would say it will be collected. But it leads to unpredictable time of collection, especially if there is data in the channel. I would prefer to have more clear understanding when resources are being released. If the tasks have huge consumption, it will require more work from GC. Maybe I just nitpicking, but I think all those things can be avoided, by small defer with closing the channel.