@@ -16,31 +16,40 @@ public static IServiceCollection AddDtmcli(this IServiceCollection services, Act
1616 services . AddOptions ( ) ;
1717 services . Configure ( setupAction ) ;
1818
19- return AddDtmcliCore ( services ) ;
19+ var op = new DtmOptions ( ) ;
20+ setupAction ( op ) ;
21+
22+ return AddDtmcliCore ( services , op ) ;
2023 }
2124
2225 public static IServiceCollection AddDtmcli ( this IServiceCollection services , IConfiguration configuration , string sectionName = "dtm" )
2326 {
2427 services . Configure < DtmOptions > ( configuration . GetSection ( sectionName ) ) ;
28+
29+ var op = configuration . GetSection ( sectionName ) . Get < DtmOptions > ( ) ?? new DtmOptions ( ) ;
2530
26- return AddDtmcliCore ( services ) ;
31+ return AddDtmcliCore ( services , op ) ;
2732 }
2833
29- private static IServiceCollection AddDtmcliCore ( IServiceCollection services )
34+ private static IServiceCollection AddDtmcliCore ( IServiceCollection services , DtmOptions options )
3035 {
31- AddHttpClient ( services ) ;
36+ AddHttpClient ( services , options ) ;
3237 AddDtmCore ( services ) ;
3338
3439 return services ;
3540 }
3641
37- private static void AddHttpClient ( IServiceCollection services )
42+ private static void AddHttpClient ( IServiceCollection services , DtmOptions options )
3843 {
3944 services . AddHttpClient ( Constant . DtmClientHttpName , client =>
4045 {
4146 client . DefaultRequestHeaders . Add ( "Accept" , "application/json" ) ;
47+ client . Timeout = TimeSpan . FromMilliseconds ( options . DtmHttpTimeout ) ;
48+ } ) ;
49+ services . AddHttpClient ( Constant . BranchClientHttpName , client =>
50+ {
51+ client . Timeout = TimeSpan . FromMilliseconds ( options . BranchHttpTimeout ) ;
4252 } ) ;
43- services . AddHttpClient ( Constant . BranchClientHttpName ) ;
4453 }
4554
4655 private static void AddDtmCore ( IServiceCollection services )
0 commit comments