External method called by clients of the Service.
(msg string)
| 34 | |
| 35 | // External method called by clients of the Service. |
| 36 | func (s *exampleService) Send(msg string) bool { |
| 37 | ctx := s.ServiceContext() |
| 38 | if ctx == nil { |
| 39 | // Service is not yet started |
| 40 | return false |
| 41 | } |
| 42 | select { |
| 43 | case s.ch <- msg: |
| 44 | return true |
| 45 | case <-ctx.Done(): |
| 46 | // Service is not running anymore. |
| 47 | return false |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func ExampleService() { |
| 52 | es := newExampleServ() |
nothing calls this directly
no test coverage detected