streamInterceptor is an example stream interceptor.
(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption)
| 89 | |
| 90 | // streamInterceptor is an example stream interceptor. |
| 91 | func streamInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { |
| 92 | var credsConfigured bool |
| 93 | for _, o := range opts { |
| 94 | _, ok := o.(*grpc.PerRPCCredsCallOption) |
| 95 | if ok { |
| 96 | credsConfigured = true |
| 97 | break |
| 98 | } |
| 99 | } |
| 100 | if !credsConfigured { |
| 101 | opts = append(opts, grpc.PerRPCCredentials(oauth.TokenSource{ |
| 102 | TokenSource: oauth2.StaticTokenSource(&oauth2.Token{AccessToken: fallbackToken}), |
| 103 | })) |
| 104 | } |
| 105 | s, err := streamer(ctx, desc, cc, method, opts...) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | return newWrappedStream(s), nil |
| 110 | } |
| 111 | |
| 112 | func callUnaryEcho(client ecpb.EchoClient, message string) { |
| 113 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
nothing calls this directly
no test coverage detected