mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
25 lines
649 B
Go
25 lines
649 B
Go
package grpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func RetryOnlyForServerStreamInterceptor(retryOpts ...grpc_retry.CallOption) grpc.StreamClientInterceptor {
|
|
return func(
|
|
ctx context.Context,
|
|
desc *grpc.StreamDesc,
|
|
cc *grpc.ClientConn,
|
|
method string,
|
|
streamer grpc.Streamer,
|
|
opts ...grpc.CallOption,
|
|
) (grpc.ClientStream, error) {
|
|
if desc.ServerStreams && !desc.ClientStreams {
|
|
return grpc_retry.StreamClientInterceptor(retryOpts...)(ctx, desc, cc, method, streamer, opts...)
|
|
}
|
|
return streamer(ctx, desc, cc, method, opts...)
|
|
}
|
|
}
|