Esempio n. 1
0
        public async Task <bool> ExistsAsync(MyCatRelationalConnection conn, bool retryOnNotExists, CancellationToken cancellationToken)
        {
            var retryCount = 0;

            while (true)
            {
                try
                {
                    await conn.OpenAsync(cancellationToken);

                    conn.Close();
                    return(true);
                }
                catch (MyCatException e)
                {
                    if (!retryOnNotExists &&
                        IsDoesNotExist(e))
                    {
                        return(false);
                    }

                    if (!RetryOnExistsFailure(e, ref retryCount))
                    {
                        throw;
                    }
                }
            }
        }
Esempio n. 2
0
        public bool Exists(MyCatRelationalConnection conn, bool retryOnNotExists = false)
        {
            var retryCount = 0;
            var giveUp     = DateTime.UtcNow + TimeSpan.FromMinutes(1);

            while (true)
            {
                try
                {
                    conn.Open();
                    conn.Close();
                    return(true);
                }
                catch (MyCatException e)
                {
                    if (!retryOnNotExists &&
                        IsDoesNotExist(e))
                    {
                        return(false);
                    }

                    if (DateTime.UtcNow > giveUp ||
                        !RetryOnExistsFailure(e, ref retryCount))
                    {
                        throw;
                    }
                }
            }
        }