public Discovery(ExtendedActorSystem system) { _system = system; _system.Settings.InjectTopLevelFallback(DiscoveryProvider.DefaultConfiguration()); var defaultImplMethod = new Lazy <string>(() => { var method = system.Settings.Config.GetString("akka.discovery.method"); if (method == "<method>") { throw new ArgumentException("No default service discovery implementation configured in \n" + "`akka.discovery.method`. Make sure to configure this setting to your preferred implementation such as \n" + "'akka-dns' in your application.conf (from the akka-discovery module)."); } return(method); }); _defaultImpl = new Lazy <ServiceDiscovery>(() => LoadServiceDiscovery(defaultImplMethod.Value)); }
public Discovery(ExtendedActorSystem system) { _system = system; _system.Settings.InjectTopLevelFallback(DiscoveryProvider.DefaultConfiguration()); _log = Logging.GetLogger(_system, GetType()); var defaultImplMethod = new Lazy <string>(() => { var method = system.Settings.Config.GetString("akka.discovery.method"); if (string.IsNullOrWhiteSpace(method) || method == "<method>") { _log.Warning( "No default service discovery implementation configured in `akka.discovery.method`.\n" + "Make sure to configure this setting to your preferred implementation such as 'config'\n" + "in your application.conf (from the akka-discovery module). Falling back to default config\n" + "based discovery method"); method = "config"; } return(method); }); _defaultImpl = new Lazy <ServiceDiscovery>(() => LoadServiceDiscovery(defaultImplMethod.Value)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); //services.AddKumuluzHealth(options => //{ // options.RegisterHealthCheck("http_health_check", new HttpHealthCheck("https://github.com/")); // options.RegisterHealthCheck("as", new DiskSpaceHealthCheck(500, SpaceUnit.Gigabyte)); //}); services.AddKumuluzConfig(options => { options.SetConfigFilePath(Path.GetFullPath("config.yaml")); options.SetExtensions(Extension.Consul, Extension.Etcd); }); services.AddKumuluzDiscovery(opt => { opt.SetConfigFilePath(Path.GetFullPath("config.yaml")); opt.SetExtension(DiscoveryExtension.Consul); }); //DiscoveryProvider.GetDiscovery().RegisterService(new RegisterOptions() { Singleton = true }); var discoverOptions1 = new DiscoverOptions { ServiceName = "test-service", Environment = "devf", AccessType = AccessType.Direct, Version = ">1.0.2" }; var res1 = DiscoveryProvider.GetDiscovery().DiscoverService(discoverOptions1); var discoverOptions2 = new DiscoverOptions { ServiceName = "test-service", Environment = "devf", AccessType = AccessType.Direct, Version = "<=1.0.0" }; var res2 = DiscoveryProvider.GetDiscovery().DiscoverService(discoverOptions2); var discoverOptions3 = new DiscoverOptions { ServiceName = "test-service", Environment = "devf", AccessType = AccessType.Direct, Version = "^2.0.2" }; var res3 = DiscoveryProvider.GetDiscovery().DiscoverService(discoverOptions3); var discoverOptions4 = new DiscoverOptions { ServiceName = "test-service", Environment = "devf", AccessType = AccessType.Direct, Version = ">1.0.2" }; var res4 = DiscoveryProvider.GetDiscovery().DiscoverService(discoverOptions4); }
public IActionResult UnregisterService() { DiscoveryProvider.GetDiscovery().UnregisterService(); return(Ok()); }