29 lines
1.2 KiB
C#
29 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace ZB.MOM.WW.Health.EntityFrameworkCore;
|
|
|
|
/// <summary>
|
|
/// Options for <see cref="DatabaseHealthCheck{TContext}"/>.
|
|
/// </summary>
|
|
/// <typeparam name="TContext">The EF Core <see cref="DbContext"/> the probe runs against.</typeparam>
|
|
public sealed class DatabaseHealthCheckOptions<TContext>
|
|
where TContext : DbContext
|
|
{
|
|
/// <summary>
|
|
/// Optional query-based probe that overrides the default
|
|
/// <see cref="Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade.CanConnectAsync(CancellationToken)"/>
|
|
/// reachability check with stricter, query-level validation (the OtOpcUa "query <c>Deployments</c>"
|
|
/// pattern). Throw to signal failure; return normally to signal success.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Example: <c>(db, ct) => db.Deployments.AsNoTracking().Take(1).ToListAsync(ct)</c>.
|
|
/// When <c>null</c>, the default <c>CanConnectAsync</c> probe is used.
|
|
/// </remarks>
|
|
public Func<TContext, CancellationToken, Task>? ProbeQuery { get; set; }
|
|
|
|
/// <summary>
|
|
/// Maximum time the probe may run before it is treated as a failure. Defaults to 10 seconds.
|
|
/// </summary>
|
|
public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(10);
|
|
}
|