MCPcopy
hub / github.com/nats-io/nats.go / reqHandler

Method reqHandler

micro/service.go:691–705  ·  view source on GitHub ↗

reqHandler invokes the service request handler and modifies service stats

(endpoint *Endpoint, req *request)

Source from the content-addressed store, hash-verified

689
690// reqHandler invokes the service request handler and modifies service stats
691func (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.
708func (s *service) Stop() error {

Callers 1

addEndpointFunction · 0.80

Calls 3

DurationMethod · 0.80
HandleMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected