github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/utils/liveness/README.md (about)

     1  # Liveness Checks Helper
     2  For applications that need to perform liveness checks, this utility creates a simple object capable of checking in with multiple routines.
     3  
     4  ## Usage 
     5  The suggested usage is to create a collector and then spawn checks from it to use in your application.
     6  
     7  Each worker gets a single Check to work from, and the collector itself is registered as an HTTP handler to respond to liveness probes.
     8  
     9  ```go
    10  multiCheck := liveness.NewCheckCollector(time.Second)
    11  
    12  http.Handle("/live", multiCheck)
    13  
    14  go worker1(multiCheck.NewCheck())
    15  go worker2(multiCheck.NewCheck())
    16  
    17  check3 = multiCheck.NewCheck()
    18  
    19  for {
    20      check3.CheckIn()
    21      // do work
    22      // ...
    23  }
    24  ```