machinebox / Progress
Licence: apache-2.0
io.Reader and io.Writer with progress and remaining time estimation
Stars: ✭ 388
Labels
Projects that are alternatives of or similar to Progress
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-95.1%)
Mutual labels: io
Storage
An iOS library for fast, easy, and safe threaded disk I/O.
Stars: ✭ 259 (-33.25%)
Mutual labels: io
toyhttpd
I/O 模型练手代码,分别使用阻塞式 I/O、select、poll 和 epoll 和 Java NIO 实现了简单的 HTTP Server
Stars: ✭ 43 (-88.92%)
Mutual labels: io
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-82.22%)
Mutual labels: io
eliminate
Delete files and directories without all the bullshit.
Stars: ✭ 51 (-86.86%)
Mutual labels: io
core
The XP Framework is an all-purpose, object oriented PHP framework.
Stars: ✭ 13 (-96.65%)
Mutual labels: io
PyTOUGH
A Python library for automating TOUGH2 simulations of subsurface fluid and heat flow
Stars: ✭ 64 (-83.51%)
Mutual labels: io
HiFramework.Unity
Based on component to manage project's core logic and module used in unity3d
Stars: ✭ 22 (-94.33%)
Mutual labels: io
Android Io18
A summary of all the important Android related launches, talks, discussions at the Google I/O 2018
Stars: ✭ 373 (-3.87%)
Mutual labels: io
tar
Memory-efficient, streaming implementation of the tar archive format in Dart
Stars: ✭ 18 (-95.36%)
Mutual labels: io
progress
io.Reader
and io.Writer
with progress and remaining time estimation.
Usage
ctx := context.Background()
// get a reader and the total expected number of bytes
s := `Now that's what I call progress`
size := len(s)
r := progress.NewReader(strings.NewReader(s))
// Start a goroutine printing progress
go func() {
ctx := context.Background()
progressChan := progress.NewTicker(ctx, r, size, 1*time.Second)
for p := range progressChan {
fmt.Printf("\r%v remaining...", p.Remaining().Round(time.Second))
}
fmt.Println("\rdownload is completed")
}()
// use the Reader as normal
if _, err := io.Copy(dest, r); err != nil {
log.Fatalln(err)
}
- Wrap an
io.Reader
orio.Writer
withNewReader
andNewWriter
respectively - Capture the total number of expected bytes
- Use
progress.NewTicker
to get a channel on which progress updates will be sent - Start a Goroutine to periodically check the progress, and do something with it - like log it
- Use the readers and writers as normal
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].