ServiceContext returns context that this service uses internally for controlling its lifecycle. It is the same context that is passed to Starting and Running functions, and is based on context passed to the service via StartAsync. Before service enters Starting state, there is no context. This cont
()
| 275 | // |
| 276 | // This is not part of Service interface, and clients of the Service should not use it. |
| 277 | func (b *BasicService) ServiceContext() context.Context { |
| 278 | s := b.State() |
| 279 | if s == New { |
| 280 | return nil |
| 281 | } |
| 282 | // no need for locking, as we have checked the state. |
| 283 | return b.serviceContext |
| 284 | } |
| 285 | |
| 286 | // AwaitRunning is part of Service interface. |
| 287 | func (b *BasicService) AwaitRunning(ctx context.Context) error { |