Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/libfor/progress

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/libfor/progress

  • v0.1.0-alpha
  • Source
  • Go
  • Socket score

Version published
Created
Source

⏱️ the progress.Reader interface

The io.Reader of reporting progress.


Go Reference Run unit tests

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.

FAQs

Package last updated on 27 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc