StopAsync is part of Service interface.
()
| 229 | |
| 230 | // StopAsync is part of Service interface. |
| 231 | func (b *BasicService) StopAsync() { |
| 232 | if s := b.State(); s == Stopping || s == Terminated || s == Failed { |
| 233 | // no need to do anything |
| 234 | return |
| 235 | } |
| 236 | |
| 237 | terminated, _ := b.switchState(New, Terminated, func() { |
| 238 | // Service wasn't started yet, and it won't be now. |
| 239 | // Notify waiters and listeners. |
| 240 | close(b.runningWaitersCh) |
| 241 | close(b.terminatedWaitersCh) |
| 242 | b.notifyListeners(func(l Listener) { l.Terminated(New) }, true) |
| 243 | }) |
| 244 | |
| 245 | if !terminated { |
| 246 | // Service is Starting or Running. Just cancel the context (it must exist, |
| 247 | // as it is created when switching from New to Starting state) |
| 248 | b.serviceCancel() |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | // ServiceContext returns context that this service uses internally for controlling its lifecycle. It is the same context that |
| 253 | // is passed to Starting and Running functions, and is based on context passed to the service via StartAsync. |
nothing calls this directly
no test coverage detected