code: func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor {
  	n := len(interceptors)
  
  	if n > 1 {
  		lastI := n - 1
  		return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
  			var (
  				chainHandler grpc.StreamHandler
  				curI         int
  			)
  
  			chainHandler = func(currentSrv interface{}, currentStream grpc.ServerStream) error {
  				if curI == lastI {
  					return handler(currentSrv, currentStream)
  				}
  				curI++
  				err := interceptors[curI](currentSrv, currentStream, info, chainHandler)
  				curI--
  				return err
  			}
  
  			return interceptors[0](srv, stream, info, chainHandler)
  		}
  	}
  
  	if n == 1 {
  		return interceptors[0]
  	}
  
  	// n == 0; Dummy interceptor maintained for backward compatibility to avoid returning nil.
  	return func(srv interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
  		return handler(srv, stream)
  	}
  }
docs: // ChainStreamServer creates a single interceptor out of a chain of many interceptors.
  //
  // Execution is done in left-to-right order, including passing of context.
  // For example ChainUnaryServer(one, two, three) will execute one before two before three.
  // If you want to pass context between interceptors, use WrapServerStream.