|
23 | 23 | package org.wsd.app.config; |
24 | 24 |
|
25 | 25 | import io.grpc.ManagedChannelBuilder; |
| 26 | +import lombok.RequiredArgsConstructor; |
26 | 27 | import net.devh.boot.grpc.client.channelfactory.GrpcChannelConfigurer; |
27 | 28 | import org.springframework.beans.factory.annotation.Autowired; |
28 | 29 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; |
29 | 30 | import org.springframework.context.annotation.Bean; |
30 | 31 | import org.springframework.context.annotation.Configuration; |
31 | 32 | import org.wsd.app.grpc.interceptor.ErrorHandlingClientInterceptor; |
| 33 | +import org.wsd.app.grpc.interceptor.GrpcClientInterceptor; |
32 | 34 |
|
33 | 35 | @Configuration |
34 | 36 | @ImportAutoConfiguration({ |
|
40 | 42 | net.devh.boot.grpc.client.autoconfigure.GrpcDiscoveryClientAutoConfiguration.class, |
41 | 43 | net.devh.boot.grpc.common.autoconfigure.GrpcCommonCodecAutoConfiguration.class, |
42 | 44 | }) |
| 45 | +@RequiredArgsConstructor |
43 | 46 | public class GrpcConfig { |
44 | 47 |
|
45 | 48 |
|
46 | | - @Autowired |
47 | | - private ErrorHandlingClientInterceptor errorHandlingClientInterceptor; |
| 49 | + private final ErrorHandlingClientInterceptor errorHandlingClientInterceptor; |
| 50 | + private final GrpcClientInterceptor grpcClientInterceptor; |
48 | 51 |
|
49 | 52 | @Bean |
50 | 53 | public GrpcChannelConfigurer clientInterceptorConfigurer() { |
51 | 54 | return (channelBuilder, name) -> { |
52 | | - if (channelBuilder instanceof ManagedChannelBuilder) { |
| 55 | + if (channelBuilder != null) { |
53 | 56 | channelBuilder.intercept(errorHandlingClientInterceptor); |
| 57 | + channelBuilder.intercept(grpcClientInterceptor); |
54 | 58 | } |
55 | 59 | }; |
56 | 60 | } |
|
0 commit comments