private async Task <DeleteResult> DeleteWithChildren(DeleteRequest request)
        {
            while (true)
            {
                var children = await GetChildrenAsync(new GetChildrenRequest(request.Path)).ConfigureAwait(false);

                if (!children.IsSuccessful)
                {
                    return(DeleteResult.Unsuccessful(children.Status, request.Path, children.Exception));
                }

                foreach (var name in children.ChildrenNames)
                {
                    var deleted = await DeleteWithChildren(new DeleteRequest(ZooKeeperPath.Combine(request.Path, name))).ConfigureAwait(false);

                    if (!deleted.IsSuccessful)
                    {
                        return(DeleteResult.Unsuccessful(deleted.Status, request.Path, deleted.Exception));
                    }
                }

                var result = await ExecuteOperation(new DeleteOperation(request)).ConfigureAwait(false);

                if (result.Status != ZooKeeperStatus.NodeHasChildren)
                {
                    return(result);
                }

                // Note(kungurtsev): someone has created a new child since we checked, delete it again.
            }
        }
        public void Split_followed_by_Combine_should_not_change_path(string path)
        {
            var expected = path;

            for (var i = 0; i < 10; i++)
            {
                path = ZooKeeperPath.Combine(ZooKeeperPath.Split(path));
            }

            path.Should().Be(expected);
        }
 public void Combine_should_work_correctly_for_two_segments(string basePath, string relativePath, string expected)
 {
     ZooKeeperPath.Combine(basePath, relativePath).Should().Be(expected);
 }
 public void Combine_should_work_correctly_for_multiple_segments(string[] segments, string expected)
 {
     ZooKeeperPath.Combine(segments).Should().Be(expected);
 }
 public string BuildReplicaPath([NotNull] string environment, [NotNull] string application, [NotNull] string replica) =>
 ZooKeeperPath.Combine(BuildApplicationPath(environment, application), Escape(replica));
 public string BuildApplicationPath([NotNull] string environment, [NotNull] string application) =>
 ZooKeeperPath.Combine(BuildEnvironmentPath(environment), Escape(application));