healthz icon indicating copy to clipboard operation
healthz copied to clipboard

Support stateful tests

Open bendecoste opened this issue 4 years ago • 0 comments

Hey!

I would like to add some custom tests that check something on an instance of my server. For example

s := &Server{
  database: MyDatabase
}

healthz.RegisterTest("db-alive", s.checkDb)

Where checkDb would implement TestFunc. However, since the registry is global, the above is problematic. Things like tests, where I will make several instances of my Server, will panic.

Would it be possible to use a non-global registry? Or support this use case some other way?

Thanks!

bendecoste avatar Mar 16 '20 20:03 bendecoste