MCPcopy
hub / github.com/grafana/dskit / serviceThatStopsOnItsOwnAfterTimeout

Function serviceThatStopsOnItsOwnAfterTimeout

services/manager_test.go:286–295  ·  view source on GitHub ↗
(timeout time.Duration)

Source from the content-addressed store, hash-verified

284}
285
286func serviceThatStopsOnItsOwnAfterTimeout(timeout time.Duration) Service {
287 return NewBasicService(nil, func(serviceContext context.Context) error {
288 select {
289 case <-serviceContext.Done():
290 return nil
291 case <-time.After(timeout):
292 return nil
293 }
294 }, nil)
295}
296
297func serviceThatDoesntDoAnything() Service {
298 // but respects StopAsync and stops.

Calls 3

NewBasicServiceFunction · 0.85
DoneMethod · 0.65
AfterMethod · 0.65

Tested by

no test coverage detected