chainStreamClientInterceptors chains all stream client interceptors into one.
(cc *ClientConn)
| 549 | |
| 550 | // chainStreamClientInterceptors chains all stream client interceptors into one. |
| 551 | func chainStreamClientInterceptors(cc *ClientConn) { |
| 552 | interceptors := cc.dopts.chainStreamInts |
| 553 | // Prepend dopts.streamInt to the chaining interceptors if it exists, since streamInt will |
| 554 | // be executed before any other chained interceptors. |
| 555 | if cc.dopts.streamInt != nil { |
| 556 | interceptors = append([]StreamClientInterceptor{cc.dopts.streamInt}, interceptors...) |
| 557 | } |
| 558 | var chainedInt StreamClientInterceptor |
| 559 | if len(interceptors) == 0 { |
| 560 | chainedInt = nil |
| 561 | } else if len(interceptors) == 1 { |
| 562 | chainedInt = interceptors[0] |
| 563 | } else { |
| 564 | chainedInt = func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, streamer Streamer, opts ...CallOption) (ClientStream, error) { |
| 565 | return interceptors[0](ctx, desc, cc, method, getChainStreamer(interceptors, 0, streamer), opts...) |
| 566 | } |
| 567 | } |
| 568 | cc.dopts.streamInt = chainedInt |
| 569 | } |
| 570 | |
| 571 | // getChainStreamer recursively generate the chained client stream constructor. |
| 572 | func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStreamer Streamer) Streamer { |
no test coverage detected