Exemplo n.º 1
0
        public async Task ChangePublishStateAsync(MediumMessage message, StatusName state)
        {
            var connection = this.DbConnection;

            var sql = $"UPDATE `{_initializer.GetPublishedTableName()}` SET `Retries` = @Retries,`ExpiresAt` = @ExpiresAt,`StatusName`=@StatusName WHERE `Id`=@Id;";

            await connection.ExecuteAsync(sql, new
            {
                Id = message.DbId,
                message.Retries,
                message.ExpiresAt,
                StatusName = state.ToString("G")
            }, transaction : DbTransaction);
        }
        public async Task ChangePublishStateAsync(MediumMessage message, StatusName state)
        {
            await using var connection = new MySqlConnection(_options.Value.ConnectionString);

            var sql = $"UPDATE `{_initializer.GetPublishedTableName()}` SET `Retries` = @Retries,`ExpiresAt` = @ExpiresAt,`StatusName`=@StatusName WHERE `Id`=@Id;";

            await connection.ExecuteAsync(sql, new
            {
                Id = message.DbId,
                message.Retries,
                message.ExpiresAt,
                StatusName = state.ToString("G")
            });
        }
Exemplo n.º 3
0
        public async Task ProcessAsync(ProcessingContext context)
        {
            var tables = new[]
            {
                _initializer.GetPublishedTableName(),
                _initializer.GetReceivedTableName()
            };

            foreach (var table in tables)
            {
                _logger.LogDebug($"Collecting expired data from table: {table}");

                int deletedCount;
                var time = DateTime.Now;
                do
                {
                    deletedCount = await _storage.DeleteExpiresAsync(table, time, ItemBatch, context.CancellationToken);

                    if (deletedCount != 0)
                    {
                        await context.WaitAsync(_delay);

                        context.ThrowIfStopping();
                    }
                } while (deletedCount != 0);
            }

            await context.WaitAsync(_waitingInterval);
        }
Exemplo n.º 4
0
 public PostgreSqlMonitoringApi(IDbContextProvider <TDbContext> dbContextProvider, IOptions <EFOptions> options, IStorageInitializer initializer)
     : base(dbContextProvider)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _pubName = initializer.GetPublishedTableName();
     _recName = initializer.GetReceivedTableName();
 }
 public SqliteMonitoringApi(
     IOptions <SqliteOptions> options,
     IStorageInitializer initializer)
 {
     _options   = options;
     _published = initializer.GetPublishedTableName();
     _received  = initializer.GetReceivedTableName();
 }
Exemplo n.º 6
0
        public async Task ChangePublishStateAsync(MediumMessage message, StatusName state)
        {
            var sql =
                $"UPDATE `{_initializer.GetPublishedTableName()}` SET `Retries` = @Retries,`ExpiresAt` = @ExpiresAt,`StatusName` = @StatusName WHERE `Id` = @Id";
            var sqlParam = new
            {
                Id         = message.DbId,
                Retries    = message.Retries,
                ExpiresAt  = message.ExpiresAt,
                StatusName = state.ToString("G")
            };

            using (var connection = new SqliteConnection(_options.Value.ConnectionString))
            {
                await connection.ExecuteAsync(sql, sqlParam);
            };
        }
Exemplo n.º 7
0
 public MySqlMonitoringApi(
     IDbContextProvider <TDbContext> dbContextProvider,
     IStorageInitializer initializer)
     : base(dbContextProvider)
 {
     _pubName = initializer.GetPublishedTableName();
     _recName = initializer.GetReceivedTableName();
 }
 public OracleDataStorage(
     IOptions <OracleOptions> options,
     IOptions <CapOptions> capOptions,
     IStorageInitializer initializer)
 {
     _options     = options;
     _capOptions  = capOptions;
     _initializer = initializer;
     _pubName     = initializer.GetPublishedTableName();
     _recName     = initializer.GetReceivedTableName();
 }
Exemplo n.º 9
0
 public PostgreSqlDataStorage(
     IOptions <PostgreSqlOptions> options,
     IOptions <CapOptions> capOptions,
     IStorageInitializer initializer)
 {
     _capOptions  = capOptions;
     _initializer = initializer;
     _options     = options;
     _pubName     = initializer.GetPublishedTableName();
     _recName     = initializer.GetReceivedTableName();
 }
 public SmartSqlDataStorage(
     IOptions <CapOptions> capOptions,
     IStorageInitializer initializer,
     ICapRepository capRepository)
 {
     _capOptions    = capOptions;
     _initializer   = initializer;
     _capRepository = capRepository;
     _pubName       = initializer.GetPublishedTableName();
     _recName       = initializer.GetReceivedTableName();
 }
Exemplo n.º 11
0
 public SqliteDataStorage(
     IOptions <SqliteOptions> options,
     IOptions <CapOptions> capOptions,
     IStorageInitializer initializer,
     ISerializer serializer)
 {
     _capOptions  = capOptions;
     _options     = options;
     _initializer = initializer;
     _serializer  = serializer;
     _pubName     = initializer.GetPublishedTableName();
     _recName     = initializer.GetReceivedTableName();
 }
 public PostgreSqlDataStorage(
     IOptions <EFOptions> options,
     IDbContextProvider <TDbContext> dbContextProvider,
     IOptions <CapOptions> capOptions,
     IStorageInitializer initializer)
     : base(dbContextProvider)
 {
     _capOptions  = capOptions;
     _initializer = initializer;
     _options     = options;
     _pubName     = initializer.GetPublishedTableName();
     _recName     = initializer.GetReceivedTableName();
 }
Exemplo n.º 13
0
 public SqlServerMonitoringApi(IOptions <SqlServerOptions> options, IStorageInitializer initializer)
 {
     _options = options.Value ?? throw new ArgumentNullException(nameof(options));
     _pubName = initializer.GetPublishedTableName();
     _recName = initializer.GetReceivedTableName();
 }
 public MySqlMonitoringApi(IOptions <MySqlOptions> options, IStorageInitializer initializer)
 {
     _options = options;
     _pubName = initializer.GetPublishedTableName();
     _recName = initializer.GetReceivedTableName();
 }
Exemplo n.º 15
0
 public SmartSqlMonitoringApi(IStorageInitializer initializer, ICapRepository capRepository)
 {
     _capRepository = capRepository;
     _pubName       = initializer.GetPublishedTableName();
     _recName       = initializer.GetReceivedTableName();
 }
Exemplo n.º 16
0
 public PostgreSqlMonitoringApi(IOptions <PostgreSqlOptions> options, IStorageInitializer initializer)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _pubName = initializer.GetPublishedTableName();
     _recName = initializer.GetReceivedTableName();
 }