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