1- using System ;
2- using dotnet_etcd ;
3- using dotnet_etcd . interfaces ;
4- using Etcd . Microsoft . Extensions . Configuration . Settings ;
5-
6- namespace Etcd . Microsoft . Extensions . Configuration . Client ;
7-
8- /// <summary>
9- /// Provides etcd client factory
10- /// </summary>
11- public class EtcdClientFactory : IEtcdClientFactory
12- {
13- /// <summary>
14- /// Initializes a new instance of the <see cref="EtcdClientFactory" /> class.
15- /// </summary>
16- /// <param name="settings">The settings.</param>
17- /// <exception cref="ArgumentNullException">settings</exception>
18- public EtcdClientFactory ( IEtcdSettings ? settings = null )
19- {
20- var environmentSetting = EnvironmentSettingsFactory . Create ( ) ;
21-
22- Settings = new EtcdSettings ( settings ? . ConnectionString ?? environmentSetting . ConnectionString ) ;
23- }
24-
25- /// <summary>
26- /// Gets the settings.
27- /// </summary>
28- /// <value>
29- /// The settings.
30- /// </value>
31- public IEtcdSettings Settings { get ; }
32-
33- /// <summary>
34- /// Creates the etcd client instance.
35- /// </summary>
36- /// <returns></returns>
37- public IEtcdClient Create ( )
38- {
39- if ( string . IsNullOrEmpty ( Settings . ConnectionString ) )
40- throw new EtcdConfigurationException ( "Connection string is missing, should be passed in AddEtcd parameters or set in environment variables." ) ;
41-
42- return new EtcdClient ( Settings . ConnectionString ) ;
43- }
1+ using System ;
2+ using dotnet_etcd ;
3+ using dotnet_etcd . interfaces ;
4+ using Etcd . Microsoft . Extensions . Configuration . Settings ;
5+
6+ namespace Etcd . Microsoft . Extensions . Configuration . Client ;
7+
8+ /// <summary>
9+ /// Provides etcd client factory
10+ /// </summary>
11+ public class EtcdClientFactory : IEtcdClientFactory
12+ {
13+ /// <summary>
14+ /// Initializes a new instance of the <see cref="EtcdClientFactory" /> class.
15+ /// </summary>
16+ /// <param name="settings">The settings.</param>
17+ /// <exception cref="ArgumentNullException">settings</exception>
18+ public EtcdClientFactory ( IEtcdSettings ? settings = null )
19+ {
20+ var environmentSetting = EnvironmentSettingsFactory . Create ( ) ;
21+
22+ Settings = new EtcdSettings ( settings ? . ConnectionString ?? environmentSetting . ConnectionString ) ;
23+ }
24+
25+ /// <summary>
26+ /// Gets the settings.
27+ /// </summary>
28+ /// <value>
29+ /// The settings.
30+ /// </value>
31+ public IEtcdSettings Settings { get ; }
32+
33+ /// <summary>
34+ /// Creates the etcd client instance.
35+ /// </summary>
36+ /// <returns></returns>
37+ public IEtcdClient Create ( )
38+ {
39+ if ( string . IsNullOrEmpty ( Settings . ConnectionString ) )
40+ throw new EtcdConfigurationException ( "Connection string is missing, should be passed in AddEtcd parameters or set in environment variables." ) ;
41+
42+ return new EtcdClient ( Settings . ConnectionString , ssl : Settings . ConnectionString ! . StartsWith ( "https" ) ) ;
43+ }
4444}
0 commit comments