public async Task Process(ProcessingContext context)
        {
            try
            {
                var tables = new[] { initializer.GetTableName() };

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

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

                        if (deletedCount == ItemBatch)
                        {
                            await Task.Delay(poleOptions.ExpiredEventsPreBulkDeleteDelaySeconds * 1000);
                        }
                    } while (deletedCount == ItemBatch);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"{nameof(ExpiredEventsCollectorProcessor)} Process Error");
            }
            finally
            {
                await Task.Delay(poleOptions.ExpiredEventsCollectIntervalSeconds * 1000);
            }
        }
 public PostgreSqlEventStorage(IOptions <PostgreSqlOptions> postgreSqlOptions, IOptions <PoleEventBusOption> producerOptions, IEventStorageInitializer eventStorageInitializer)
 {
     this.producerOptions         = producerOptions.Value;
     this.options                 = postgreSqlOptions.Value;
     this.eventStorageInitializer = eventStorageInitializer;
     tableName = eventStorageInitializer.GetTableName();
 }