All Projects → machinebox → Progress

machinebox / Progress

Licence: apache-2.0
io.Reader and io.Writer with progress and remaining time estimation

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

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
GeoJSON.jl
Utilities for working with GeoJSON data in Julia
Stars: ✭ 46 (-88.14%)
Mutual labels:  io
Storage
An iOS library for fast, easy, and safe threaded disk I/O.
Stars: ✭ 259 (-33.25%)
Mutual labels:  io
reactor
Asynchronous Event Driven IO for .NET
Stars: ✭ 40 (-89.69%)
Mutual labels:  io
toyhttpd
I/O 模型练手代码,分别使用阻塞式 I/O、select、poll 和 epoll 和 Java NIO 实现了简单的 HTTP Server
Stars: ✭ 43 (-88.92%)
Mutual labels:  io
sio-go
Authenticated encryption for streams in Go
Stars: ✭ 21 (-94.59%)
Mutual labels:  io
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-82.22%)
Mutual labels:  io
Scnlib
scanf for modern C++
Stars: ✭ 359 (-7.47%)
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
BBIOConfig
A GUI for the BB universal IO
Stars: ✭ 39 (-89.95%)
Mutual labels:  io
io-handbook
Handbook of IO
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
crifan.github.io
用于利用github.io去存放crifan的静态页面
Stars: ✭ 32 (-91.75%)
Mutual labels:  io
Monio
Async-capable IO monad for JS
Stars: ✭ 311 (-19.85%)
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
Ogar3
A better version of Ogar
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
Libuv
Cross-platform asynchronous I/O
Stars: ✭ 18,615 (+4697.68%)
Mutual labels:  io
tar
Memory-efficient, streaming implementation of the tar archive format in Dart
Stars: ✭ 18 (-95.36%)
Mutual labels:  io

progress GoDoc Build Status Go Report Card

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)
}
  1. Wrap an io.Reader or io.Writer with NewReader and NewWriter respectively
  2. Capture the total number of expected bytes
  3. Use progress.NewTicker to get a channel on which progress updates will be sent
  4. Start a Goroutine to periodically check the progress, and do something with it - like log it
  5. 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].