StartAndAwaitRunning starts the service, and then waits until it reaches Running state. If service fails to start, its failure case is returned. Service must be in New state when this function is called. Notice that context passed to the service for starting is the same as context used for waiting!
(ctx context.Context, service Service)
| 101 | // Notice that context passed to the service for starting is the same as context used for waiting! |
| 102 | // If you need these contexts to be different, please use StartAsync and AwaitRunning directly. |
| 103 | func StartAndAwaitRunning(ctx context.Context, service Service) error { |
| 104 | err := service.StartAsync(ctx) |
| 105 | if err != nil { |
| 106 | return err |
| 107 | } |
| 108 | |
| 109 | err = service.AwaitRunning(ctx) |
| 110 | if e := service.FailureCase(); e != nil { |
| 111 | return e |
| 112 | } |
| 113 | |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | // StopAndAwaitTerminated asks service to stop, and then waits until service reaches Terminated |
| 118 | // or Failed state. If service ends in Terminated state, this function returns error. On Failed state, |