| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| package main |
|
|
| import ( |
| "context" |
| "errors" |
| "os" |
| "runtime" |
| "runtime/pprof" |
| ) |
|
|
| func init() { |
| register("Kubernetes25331", Kubernetes25331) |
| } |
|
|
| type watchChan_kubernetes25331 struct { |
| ctx context.Context |
| cancel context.CancelFunc |
| resultChan chan bool |
| errChan chan error |
| } |
|
|
| func (wc *watchChan_kubernetes25331) Stop() { |
| wc.errChan <- errors.New("Error") |
| wc.cancel() |
| } |
|
|
| func (wc *watchChan_kubernetes25331) run() { |
| select { |
| case err := <-wc.errChan: |
| errResult := len(err.Error()) != 0 |
| wc.cancel() |
| wc.resultChan <- errResult |
| case <-wc.ctx.Done(): |
| } |
| } |
|
|
| func NewWatchChan_kubernetes25331() *watchChan_kubernetes25331 { |
| ctx, cancel := context.WithCancel(context.Background()) |
| return &watchChan_kubernetes25331{ |
| ctx: ctx, |
| cancel: cancel, |
| resultChan: make(chan bool), |
| errChan: make(chan error), |
| } |
| } |
|
|
| func Kubernetes25331() { |
| prof := pprof.Lookup("goroutineleak") |
| defer func() { |
| |
| for i := 0; i < yieldCount; i++ { |
| runtime.Gosched() |
| } |
| prof.WriteTo(os.Stdout, 2) |
| }() |
| go func() { |
| wc := NewWatchChan_kubernetes25331() |
| go wc.run() |
| go wc.Stop() |
| }() |
| } |
|
|