Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish, close all codecs which will cancel pending requests/subscriptions.
()
| 229 | // Stop will stop reading new requests, wait for stopPendingRequestTimeout to allow pending requests to finish, |
| 230 | // close all codecs which will cancel pending requests/subscriptions. |
| 231 | func (s *Server) Stop() { |
| 232 | if atomic.CompareAndSwapInt32(&s.run, 1, 0) { |
| 233 | log.Debug("RPC Server shutdown initiatied") |
| 234 | s.codecsMu.Lock() |
| 235 | defer s.codecsMu.Unlock() |
| 236 | s.codecs.Each(func(c interface{}) bool { |
| 237 | c.(ServerCodec).Close() |
| 238 | return true |
| 239 | }) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // createSubscription will call the subscription callback and returns the subscription id or error. |
| 244 | func (s *Server) createSubscription(ctx context.Context, c ServerCodec, req *serverRequest) (ID, error) { |