Closed HopHouse closed 4 years ago
Hello! Thank you, let's make progress bar great again 😎
I'm reluctant to change main API, therefore I've pushed a patch to ignore-complete branch, which should fix your use case with minor API change. Basically you should SetTotal(total, false)
to disable completion on current == total
and then to enable it SetTotal(total, true)
.
Can you please check it out?
To quickly test you should append following line to go.mod
file of your project.
replace github.com/vbauerster/mpb/v5 => /path/to/clonned/ignore-complete/branch
Effectively, it is a better implementation with minor changes. It fits my needs and should fix #48 too. Thank you.
@vbauerster, how should we proceed to merge it ?
I've merged ignore-complete
branch into master, will bump tag eventually.
Hello,
Firstly thank you for your package, it really great ! I am barely new to GO, but I think I tried everything in order to make a multiple bar with a one that wait for the second and where both have a dynamic total. There is a related issue to this #48, but the workaround found dit not satisfy me because I use the progress bar to display a coherent value of the total. So, I cannot use the +1 to total trick.
I have 2 jobs that are running in parallel, one which do a task and populate a second one. Based on the entry it received, the second one is processing the entry, but way faster than the first. Both are rendered in the progress bar. At the end, I would have the same number of total elements.
It results that the task2 is faster than the one and complete before it. The first task is continuing and add more tasks to the second but it is not updated because the second bar is already marked as Completed.
The only workaround I found was to use a total to 0 with the function
SetTotal(newTotal, false)
. It is working but the purpose of the bar is not satisfied. There is no more bar, just a counter.I think it would be nice to have the possibility to set a bar that does not mark it as completed when the program increases the counter and that counter reaches the total. It would be pretty useful in a context of multiple bars that display the states of different functions that do not take the same time to process and are related to each other.
I am not sure about how to implement this. I tried to find a way and found two functions where the bar is set to be completed and where I would not to.
I did the following modification in order to be able to achieve it and it is working.
Not sure about naming convention and if I update code in the right places, but it is working. Feel free to improve the code or comment the way I implemented it.