re-implement data usage crawler to be more efficient (#9075)

Implementation overview: 

https://gist.github.com/klauspost/1801c858d5e0df391114436fdad6987b
This commit is contained in:
Klaus Post
2020-03-19 00:19:29 +01:00
committed by GitHub
parent 7fdeb44372
commit 8d98662633
61 changed files with 2895 additions and 543 deletions

View File

@@ -17,6 +17,7 @@
package cmd
import (
"context"
"os"
"os/exec"
"syscall"
@@ -35,11 +36,22 @@ const (
var globalServiceSignalCh chan serviceSignal
// GlobalServiceDoneCh - Global service done channel.
var GlobalServiceDoneCh chan struct{}
var GlobalServiceDoneCh <-chan struct{}
// GlobalContext context that is canceled when server is requested to shut down.
var GlobalContext context.Context
// cancelGlobalContext can be used to indicate server shutdown.
var cancelGlobalContext context.CancelFunc
// Initialize service mutex once.
func init() {
GlobalServiceDoneCh = make(chan struct{})
initGlobalContext()
}
func initGlobalContext() {
GlobalContext, cancelGlobalContext = context.WithCancel(context.Background())
GlobalServiceDoneCh = GlobalContext.Done()
globalServiceSignalCh = make(chan serviceSignal)
}