1
2
3
4
5
12 package main
13
14 import (
15 "context"
16 "errors"
17 "os"
18 "runtime"
19 "runtime/pprof"
20 )
21
22 func init() {
23 register("Kubernetes25331", Kubernetes25331)
24 }
25
26 type watchChan_kubernetes25331 struct {
27 ctx context.Context
28 cancel context.CancelFunc
29 resultChan chan bool
30 errChan chan error
31 }
32
33 func (wc *watchChan_kubernetes25331) Stop() {
34 wc.errChan <- errors.New("Error")
35 wc.cancel()
36 }
37
38 func (wc *watchChan_kubernetes25331) run() {
39 select {
40 case err := <-wc.errChan:
41 errResult := len(err.Error()) != 0
42 wc.cancel()
43 wc.resultChan <- errResult
44 case <-wc.ctx.Done():
45 }
46 }
47
48 func NewWatchChan_kubernetes25331() *watchChan_kubernetes25331 {
49 ctx, cancel := context.WithCancel(context.Background())
50 return &watchChan_kubernetes25331{
51 ctx: ctx,
52 cancel: cancel,
53 resultChan: make(chan bool),
54 errChan: make(chan error),
55 }
56 }
57
58 func Kubernetes25331() {
59 prof := pprof.Lookup("goroutineleak")
60 defer func() {
61
62 for i := 0; i < yieldCount; i++ {
63 runtime.Gosched()
64 }
65 prof.WriteTo(os.Stdout, 2)
66 }()
67 go func() {
68 wc := NewWatchChan_kubernetes25331()
69 go wc.run()
70 go wc.Stop()
71 }()
72 }
73
View as plain text