public static IServiceCollection AddDiscoveryClient(this IServiceCollection services, DiscoveryOptions discoveryOptions, IDiscoveryLifecycle lifecycle = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (discoveryOptions == null) { throw new ArgumentNullException(nameof(discoveryOptions)); } if (discoveryOptions.ClientType == DiscoveryClientType.EUREKA) { EurekaClientOptions clientOptions = discoveryOptions.ClientOptions as EurekaClientOptions; if (clientOptions == null) { throw new ArgumentException("Missing Client Options"); } services.AddSingleton <IOptionsMonitor <EurekaClientOptions> >(new OptionsMonitorWrapper <EurekaClientOptions>(clientOptions)); var regOptions = discoveryOptions.RegistrationOptions as EurekaInstanceOptions; if (regOptions == null) { clientOptions.ShouldRegisterWithEureka = false; regOptions = new EurekaInstanceOptions(); } services.AddSingleton <IOptionsMonitor <EurekaInstanceOptions> >(new OptionsMonitorWrapper <EurekaInstanceOptions>(regOptions)); AddEurekaServices(services, lifecycle); } else { throw new ArgumentException("Client type UNKNOWN"); } return(services); }
public static IServiceCollection AddDiscoveryClient(this IServiceCollection services, DiscoveryOptions discoveryOptions) { if (services == null) { throw new ArgumentNullException(nameof(services)); } if (discoveryOptions == null) { throw new ArgumentNullException(nameof(discoveryOptions)); } if (discoveryOptions.ClientType == DiscoveryClientType.UNKNOWN) { throw new ArgumentException("Client type UNKNOWN"); } return(DoAdd(services, discoveryOptions)); }