Exemple #1
0
        /// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            var appSettings = new AppSettings();

            Configuration.Bind(appSettings);
            var consulConfig = new ConsulRegistryHostConfiguration
            {
                HostName = appSettings.Consul.HostName,
                Port     = appSettings.Consul.Port
            };

            services.AddNanoFabric(() => new ConsulRegistryHost(consulConfig));
            services.AddMvc();
            services.AddOptions();
            services.AddSwaggerGen();
            services.ConfigureSwaggerGen(options =>
            {
                options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info
                {
                    Version        = "v1",
                    Title          = "Sample Web ",
                    Description    = "RESTful API for My Web Application",
                    TermsOfService = "None"
                });
                options.IncludeXmlComments(Path.Combine(PlatformServices.Default.Application.ApplicationBasePath,
                                                        "SampleService.Kestrel.xml"));
                options.DescribeAllEnumsAsStrings();
            });
        }
        public ConsulRegistryHostShould()
        {
            var configuration = new ConsulRegistryHostConfiguration()
            {
                HostName = "10.125.30.152"
            };

            _registryHost = new ConsulRegistryHost(configuration);
        }
Exemple #3
0
        public ConsulRegistryHostShould()
        {
            var configuration = new ConsulRegistryHostConfiguration()
            {
                HostName = "localhost"
            };

            _registryHost = new ConsulRegistryHost(configuration);
        }
Exemple #4
0
        public ConsulRegistryHostShould()
        {
            var configuration = new ConsulRegistryHostConfiguration()
            {
                HttpEndpoint = "http://127.0.0.1:8500", DnsEndpoint = new DnsEndpoint()
                {
                    Address = "127.0.0.1", Port = 8600
                }
            };

            _registryHost = new ConsulRegistryHost(configuration);
        }
Exemple #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            var appSettings = new AppSettings();

            Configuration.Bind(appSettings);
            var consulConfig = new ConsulRegistryHostConfiguration {
                HostName = appSettings.Consul.HostName, Port = appSettings.Consul.Port
            };

            services.AddNanophone(() => new ConsulRegistryHost(consulConfig));
            services.AddMvc();
            services.AddOptions();
        }
        private RegistryClient BuildRegistryClient(string prefixName)
        {
            var configuration = new ConsulRegistryHostConfiguration()
            {
                HostName = "localhost"
            };

            var consul = new ConsulRegistryHost(configuration);

            var registryClient = new RegistryClient(prefixName, new RoundRobinAddressRouter());

            registryClient.AddRegistryHost(consul);

            return(registryClient);
        }
Exemple #7
0
        private async Task <IRegistryHost> GetConsulRegistryHostAsync()
        {
            var configuration = new ConsulRegistryHostConfiguration()
            {
                HostName = "localhost"
            };

            var registryHost = new ConsulRegistryHost(configuration);
            await registryHost.KeyValuePutAsync("key1", "value1");

            await registryHost.KeyValuePutAsync("key2", "value2");

            await registryHost.KeyValuePutAsync("folder/key3", "value3");

            await registryHost.KeyValuePutAsync("folder/key4", "value4");

            return(registryHost);
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            var log = LogManager.GetCurrentClassLogger();

            log.Debug($"Starting {typeof(Program).Namespace}");

            var appsettings  = JsonConvert.DeserializeObject <AppSettings>(File.ReadAllText("appsettings.json"));
            var consulConfig = new ConsulRegistryHostConfiguration {
                HostName = appsettings.Consul.HostName, Port = appsettings.Consul.Port
            };
            var config = new ConfigurationBuilder()
                         .AddNanoFabricKeyValues(() => new ConsulRegistryHost(consulConfig))
                         .Build();

            var host = new WebHostBuilder()
                       .UseKestrel()
                       .UseUrls($"http://*:{PORT}")
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
        public ConsulRegistryHostShould()
        {
            var configuration = new ConsulRegistryHostConfiguration();

            _registryHost = new ConsulRegistryHost(configuration);
        }
 public static IServiceCollection AddNanoFabricConsul(this IServiceCollection services, ConsulRegistryHostConfiguration consulRegistryConfiguration)
 {
     services.AddNanoFabric(() => new ConsulRegistryHost(consulRegistryConfiguration));
     return(services);
 }