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

Function StopAndAwaitTerminated

services/services.go:120–133  ·  services/services.go::StopAndAwaitTerminated

StopAndAwaitTerminated asks service to stop, and then waits until service reaches Terminated or Failed state. If service ends in Terminated state, this function returns error. On Failed state, it returns the failure case. Other errors are possible too (eg. if context stops before service does).

(ctx context.Context, service Service)

Source from the content-addressed store, hash-verified

118// or Failed state. If service ends in Terminated state, this function returns error. On Failed state,
119// it returns the failure case. Other errors are possible too (eg. if context stops before service does).
120func StopAndAwaitTerminated(ctx context.Context, service Service) error {
121 service.StopAsync()
122 err := service.AwaitTerminated(ctx)
123 if err == nil {
124 return nil
125 }
126
127 if e := service.FailureCase(); e != nil {
128 return e
129 }
130
131 // can happen e.g. if context was canceled
132 return err
133}
134
135// DescribeService returns name of the service, if it has one, or returns string representation of the service.
136func DescribeService(service Service) string {

Calls 3

StopAsyncMethod · 0.65
AwaitTerminatedMethod · 0.65
FailureCaseMethod · 0.65