From 4c690762bd923f09c4649fb5d7f26d654828a513 Mon Sep 17 00:00:00 2001 From: nxshock Date: Wed, 3 Feb 2021 20:57:44 +0500 Subject: [PATCH] Move consts to separate file --- consts.go | 8 ++++++++ gwp.go | 8 +++----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 consts.go diff --git a/consts.go b/consts.go new file mode 100644 index 0000000..5bed223 --- /dev/null +++ b/consts.go @@ -0,0 +1,8 @@ +package gwp + +import "time" + +const ( + defaultProgressUpdatePeriod = time.Second + defaultCalculateEtaPeriod = time.Minute +) diff --git a/gwp.go b/gwp.go index 6a1a27c..c94e853 100644 --- a/gwp.go +++ b/gwp.go @@ -37,16 +37,14 @@ func New(threadCount int) *WorkerPool { var prevPos int prevTime := time.Now() - const calculateEtaPeriod = time.Minute - - tickerUpdateText := time.NewTicker(time.Second) - tickerCalculateEta := time.NewTicker(calculateEtaPeriod) + tickerUpdateText := time.NewTicker(defaultProgressUpdatePeriod) + tickerCalculateEta := time.NewTicker(defaultCalculateEtaPeriod) defer func() { tickerUpdateText.Stop() tickerCalculateEta.Stop() }() - var currentSpeed float64 // items per sec + var currentSpeed float64 // jobs per sec fmt.Fprintf(os.Stderr, endLine) for {