Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

libfor/progress

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⏱️ the progress.Reader interface

The io.Reader of reporting progress.


Go Reference Run unit tests Go Report Card

Progress monitoring is a crucial part of many applications, and deserves a simple, standardized interface.

The progress.Reader interface aims to be just that.

progress.Reader interface
    DoneChan() (done chan struct{}, completed bool)
    Count() (finished uint64, total uint64)

To drive adoption and provide practical utility, we've also included handy tools right out of the box! 📦

progress.NewLongRunningJob

🤩 If you like the idea, here's the fastest way to expose a progress.Reader.

This concurrency-safe utility makes instrumenting your long-running functions with a Reader implementation absolutely painless. Support progress and make your library consumers extremely happy!

progress.Extend(Reader)

This simple wrapper adds helpful functions to a Reader, such as estimating the remaining time:

PerSecond() float64
Remaining() time.Duration
Percentage() float64
InProgress() bool

progress.Logger(Reader)

Instantly start a goroutine that keeps an eye on a Reader and logs informative updates! 👀 Here's what it looks like today:

searching:  49% (20.69/s, 1.256483582s remaining)
searching:  56% (18.01/s, 1.221804358s remaining)
searching:  80% (20.37/s, 490.981158ms remaining)
searching: 100% (21.98/s, 0s remaining)

progress.WaitGroup

Drop in replacement for sync.WaitGroup that satisfies the Reader interface.


📝 Todo List

Here's some simple ideas for those looking to contribute.

  • Satisfy progress.Reader with just a count.
  • Return a progress.Reader from a slice or channel.
  • Create a pretty terminal progress bar.
  • Experiment with passing return types through.

About

Go library for tasks to report progress in a standard way

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.