MCPcopy
hub / github.com/grpc/grpc-go / chainStreamServerInterceptors

Function chainStreamServerInterceptors

server.go:1555–1573  ·  view source on GitHub ↗

chainStreamServerInterceptors chains all stream server interceptors into one.

(s *Server)

Source from the content-addressed store, hash-verified

1553
1554// chainStreamServerInterceptors chains all stream server interceptors into one.
1555func 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
1575func chainStreamInterceptors(interceptors []StreamServerInterceptor) StreamServerInterceptor {
1576 return func(srv any, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error {

Callers 1

NewServerFunction · 0.85

Calls 1

chainStreamInterceptorsFunction · 0.85

Tested by

no test coverage detected