Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var             config = ConfigurationHelper.GetAppSettings <ConsulOption>("ConsulConfig");
            var             option = new DefaultConsulOptionProvider().ConsulOption;
            ConsulNetClient client = new ConsulNetClient(option);

            string key = "app/keys";

            client.KVPutAsync(key, "test");

            var value = client.KVGetValueAsync(key).Result;

            Console.Write(value);

            // Demo demo = new Demo() { ID = 1, Name = "阿礼", Birth = DateTime.Now };

            BaseConsulModel demo = new BaseConsulModel()
            {
                Key = "Key", Path = "Common/EnvConfig/Key", Value = "Coding"
            };


            client.KVPutAsync <BaseConsulModel>(demo.Path, demo);

            value = client.KVGetValueAsync("app/demo").Result;
            Console.WriteLine(value);
        }
Exemplo n.º 2
0
        public async System.Threading.Tasks.Task ConsulClientTest()
        {
            var config = ConfigurationHelper.GetAppSettings <ConsulOption>("ConsulConfig");

            var             option = new DefaultConsulOptionProvider().ConsulOption;
            ConsulNetClient client = new ConsulNetClient(option);

            string key = "app/keys";
            await client.KVPutAsync(key, "test");

            var value = await client.KVGetValueAsync(key);

            Console.Write(value);

            // Demo demo = new Demo() { ID = 1, Name = "°¢Àñ", Birth = DateTime.Now };

            BaseConsulModel demo = new BaseConsulModel()
            {
                Key = "Key", Path = "Common/EnvConfig/Key", Value = "Coding"
            };


            await client.KVPutAsync <BaseConsulModel>(demo.Path, demo);

            value = await client.KVGetValueAsync("app/demo");

            Console.WriteLine(value);
        }