mirror of
https://github.com/Chipazawra/v8-1c-cluster-pde.git
synced 2024-12-25 01:32:38 +02:00
refactor
This commit is contained in:
parent
492a280cf6
commit
a2d21e95c1
@ -108,17 +108,19 @@ func Run() error {
|
||||
go RunPuller(ctx, errchan, rcli)
|
||||
default:
|
||||
{
|
||||
cancel()
|
||||
return fmt.Errorf("v8-1c-cluster-pde: %v", "undefined mode")
|
||||
errchan <- fmt.Errorf("v8-1c-cluster-pde: %v", "undefined mode")
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("v8-1c-cluster-pde: received signal %v",
|
||||
<-sigchan,
|
||||
)
|
||||
cancel()
|
||||
|
||||
return <-errchan
|
||||
select {
|
||||
case sig := <-sigchan:
|
||||
cancel()
|
||||
log.Printf("v8-1c-cluster-pde: received signal %v", sig)
|
||||
return nil
|
||||
case err := <-errchan:
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func RunPuller(ctx context.Context, errchan chan<- error, rasapi rascli.Api) {
|
||||
@ -150,7 +152,7 @@ func RunPuller(ctx context.Context, errchan chan<- error, rasapi rascli.Api) {
|
||||
}
|
||||
|
||||
func RunPusher(ctx context.Context, errchan chan<- error, rasapi rascli.Api) {
|
||||
log.Printf("v8-1c-cluster-pde: runing in %v mode pushgateway %v\n",
|
||||
log.Printf("v8-1c-cluster-pde: runing in %v mode %v\n",
|
||||
conf.MODE, fmt.Sprintf("%s:%s", conf.PUSH_HOST, conf.PUSH_PORT))
|
||||
|
||||
go pusher.New(
|
||||
@ -159,3 +161,7 @@ func RunPusher(ctx context.Context, errchan chan<- error, rasapi rascli.Api) {
|
||||
pusher.WithInterval(500),
|
||||
).Run(ctx, errchan)
|
||||
}
|
||||
|
||||
type RASCollector interface {
|
||||
Run(ctx context.Context, errchan chan<- error, rasapi rascli.Api)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user