reqHandler invokes the service request handler and modifies service stats
(endpoint *Endpoint, req *request)
| 689 | |
| 690 | // reqHandler invokes the service request handler and modifies service stats |
| 691 | func (s *service) reqHandler(endpoint *Endpoint, req *request) { |
| 692 | start := time.Now() |
| 693 | endpoint.Handler.Handle(req) |
| 694 | s.m.Lock() |
| 695 | endpoint.stats.NumRequests++ |
| 696 | endpoint.stats.ProcessingTime += time.Since(start) |
| 697 | avgProcessingTime := endpoint.stats.ProcessingTime.Nanoseconds() / int64(endpoint.stats.NumRequests) |
| 698 | endpoint.stats.AverageProcessingTime = time.Duration(avgProcessingTime) |
| 699 | |
| 700 | if req.respondError != nil { |
| 701 | endpoint.stats.NumErrors++ |
| 702 | endpoint.stats.LastError = req.respondError.Error() |
| 703 | } |
| 704 | s.m.Unlock() |
| 705 | } |
| 706 | |
| 707 | // Stop drains the endpoint subscriptions and marks the service as stopped. |
| 708 | func (s *service) Stop() error { |
no test coverage detected