public async Task SessionId_SessionPassword_ConnectionState_should_be_filled_after_connect()
        {
            (await client.ExistsAsync("/path")).EnsureSuccess();

            client.ConnectionState.Should().Be(ConnectionState.Connected);
            client.SessionId.Should().NotBe(0);
            client.SessionPassword.Should().NotBeNullOrEmpty();
        }
        private static async Task VerifyNodeDeleted(ZooKeeperClient client, string path)
        {
            var node = await client.ExistsAsync(path);

            node.EnsureSuccess();

            node.Exists.Should().BeFalse();
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddLogging(builder =>
            {
                builder
                .AddConfiguration(Configuration.GetSection("Logging"))
                .AddFilter("Microsoft", LogLevel.Warning)
                .AddConsole();
            });
            services.AddSingleton <IConfiguration>(Configuration);

            var zkClient = new ZooKeeperClient(Configuration["ZooKeeperAddress"]);

            var path  = $"/{Configuration["RootNodeName"]}";
            var exist = zkClient.ExistsAsync(path).ConfigureAwait(false).GetAwaiter().GetResult();

            if (!exist)
            {
                zkClient.CreatePersistentAsync(path, "root").ConfigureAwait(false).GetAwaiter().GetResult();
            }

            services.AddSingleton <IZooKeeperClient>(zkClient);
            services.AddMvc(options =>
            {
                options.Filters.Add(typeof(ExceptionFilter));
            });

            services.AddSwaggerGen(option =>
            {
                option.SwaggerDoc("v1", new Info {
                    Title = "API Document", Version = "v1.0"
                });

                foreach (var file in Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Where(w => w.EndsWith(".xml")))
                {
                    option.IncludeXmlComments(file);
                }
            });
        }
Esempio n. 4
0
 private async Task <NodeStat> GetNodeStat(string path)
 {
     return((await client.ExistsAsync(path)).Stat);
 }