chainStreamServerInterceptors chains all stream server interceptors into one.
(s *Server)
| 1553 | |
| 1554 | // chainStreamServerInterceptors chains all stream server interceptors into one. |
| 1555 | func chainStreamServerInterceptors(s *Server) { |
| 1556 | // Prepend opts.streamInt to the chaining interceptors if it exists, since streamInt will |
| 1557 | // be executed before any other chained interceptors. |
| 1558 | interceptors := s.opts.chainStreamInts |
| 1559 | if s.opts.streamInt != nil { |
| 1560 | interceptors = append([]StreamServerInterceptor{s.opts.streamInt}, s.opts.chainStreamInts...) |
| 1561 | } |
| 1562 | |
| 1563 | var chainedInt StreamServerInterceptor |
| 1564 | if len(interceptors) == 0 { |
| 1565 | chainedInt = nil |
| 1566 | } else if len(interceptors) == 1 { |
| 1567 | chainedInt = interceptors[0] |
| 1568 | } else { |
| 1569 | chainedInt = chainStreamInterceptors(interceptors) |
| 1570 | } |
| 1571 | |
| 1572 | s.opts.streamInt = chainedInt |
| 1573 | } |
| 1574 | |
| 1575 | func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor { |
| 1576 | return func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error { |
no test coverage detected