()
| 338 | } |
| 339 | |
| 340 | func (s *Service) stop() (err error) { |
| 341 | if !atomic.CompareAndSwapInt32(&s.stopped, 0, 1) { |
| 342 | // stopped |
| 343 | return ErrStopped |
| 344 | } |
| 345 | |
| 346 | // send cancel subscription to all databases |
| 347 | log.Info("stop subscribing all databases") |
| 348 | |
| 349 | s.subscription.Range(func(_, rawWorker interface{}) bool { |
| 350 | unpackWorker(rawWorker).stop() |
| 351 | return true |
| 352 | }) |
| 353 | |
| 354 | // close the subscription database |
| 355 | _ = s.db.Close() |
| 356 | |
| 357 | return |
| 358 | } |
| 359 | |
| 360 | func (s *Service) minerRequest(dbID proto.DatabaseID, method string, request interface{}, response interface{}) (err error) { |
| 361 | instance, err := s.getUpstream(dbID) |
no test coverage detected