in src/TriggersBinding/MySqlTableChangeMonitor.cs [96:144]
public MySqlTableChangeMonitor(
string connectionString,
string userTableId,
MySqlObject userTable,
string userFunctionId,
string leasesTableName,
IReadOnlyList<(string name, string type)> primaryKeyColumns,
IReadOnlyList<string> userTableColumns,
ITriggeredFunctionExecutor executor,
MySqlOptions mysqlOptions,
ILogger logger,
IConfiguration configuration)
{
this._connectionString = !string.IsNullOrEmpty(connectionString) ? connectionString : throw new ArgumentNullException(nameof(connectionString));
this._userTableId = userTableId;
this._userTable = userTable ?? throw new ArgumentNullException(nameof(userTable));
this._userFunctionId = userFunctionId ?? throw new ArgumentNullException(nameof(userFunctionId));
this._leasesTableName = leasesTableName ?? throw new ArgumentNullException(nameof(leasesTableName));
this._primaryKeyColumns = primaryKeyColumns ?? throw new ArgumentNullException(nameof(primaryKeyColumns));
this._userTableColumns = userTableColumns ?? throw new ArgumentNullException(nameof(userTableColumns));
this._mysqlOptions = mysqlOptions ?? throw new ArgumentNullException(nameof(mysqlOptions));
this._executor = executor ?? throw new ArgumentNullException(nameof(executor));
this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
this._primaryKeyColumnNames = this._primaryKeyColumns.Select(col => $"{col.name}");
int? configuredMaxBatchSize = configuration.GetValue<int?>(ConfigKey_MySqlTrigger_MaxBatchSize) ?? configuration.GetValue<int?>(ConfigKey_MySqlTrigger_BatchSize);
this._maxBatchSize = configuredMaxBatchSize ?? this._mysqlOptions.MaxBatchSize;
if (this._maxBatchSize <= 0)
{
throw new InvalidOperationException($"Invalid value for configuration setting '{ConfigKey_MySqlTrigger_MaxBatchSize}'. Ensure that the value is a positive integer.");
}
int? configuredPollingInterval = configuration.GetValue<int?>(ConfigKey_MySqlTrigger_PollingInterval);
this._pollingIntervalInMs = configuredPollingInterval ?? this._mysqlOptions.PollingIntervalMs;
if (this._pollingIntervalInMs <= 0)
{
throw new InvalidOperationException($"Invalid value for configuration setting '{ConfigKey_MySqlTrigger_PollingInterval}'. Ensure that the value is a positive integer.");
}
#pragma warning disable CS4014 // Queue the below tasks and exit. Do not wait for their completion.
_ = Task.Run(() =>
{
this.RunChangeConsumptionLoopAsync();
this.RunLeaseRenewalLoopAsync();
});
#pragma warning restore CS4014
}