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

Method stop

micro/service.go:905–922  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

903}
904
905func (e *Endpoint) stop() error {
906 // Drain the subscription. If the connection is closed, draining is not possible
907 // but we should still remove the endpoint from the service.
908 if err := e.subscription.Drain(); err != nil && !errors.Is(err, nats.ErrConnectionClosed) {
909 return fmt.Errorf("draining subscription for request handler: %w", err)
910 }
911 for i := 0; i < len(e.service.endpoints); i++ {
912 if e.service.endpoints[i].Subject == e.Subject {
913 if i != len(e.service.endpoints)-1 {
914 e.service.endpoints = append(e.service.endpoints[:i], e.service.endpoints[i+1:]...)
915 } else {
916 e.service.endpoints = e.service.endpoints[:i]
917 }
918 i++
919 }
920 }
921 return nil
922}
923
924func (e *Endpoint) reset() {
925 e.stats = EndpointStats{

Callers 1

StopMethod · 0.80

Calls 3

ErrorfMethod · 0.80
DrainMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected