github.com/songzhibin97/gkit@v1.2.13/watching/example/channelblock/channelblock.go (about)

     1  package main
     2  
     3  import (
     4  	"net/http"
     5  	"time"
     6  
     7  	"github.com/songzhibin97/gkit/watching"
     8  )
     9  
    10  func init() {
    11  	http.HandleFunc("/chanblock", channelBlock)
    12  	go http.ListenAndServe(":10003", nil)
    13  }
    14  
    15  func main() {
    16  	w := watching.NewWatching(
    17  		watching.WithCollectInterval("5s"),
    18  		watching.WithCoolDown("1m"),
    19  		watching.WithDumpPath("/tmp"),
    20  		watching.WithTextDump(),
    21  		watching.WithGoroutineDump(10, 25, 2000, 74),
    22  	)
    23  	w.EnableGoroutineDump().Start()
    24  	time.Sleep(time.Hour)
    25  }
    26  
    27  var nilCh chan int
    28  
    29  func channelBlock(wr http.ResponseWriter, req *http.Request) {
    30  	nilCh <- 1
    31  }