Skip to content

Commit afc1aa2

Browse files
committed
Upgrade to Akka.Hosting 1.5.55.1 with simplified connectivity check API
This commit updates Akka.Persistence.Azure to use the improved builder API from Akka.Hosting 1.5.55.1 (released via akkadotnet/Akka.Hosting#691). **Changes:** - Upgraded Akka.Hosting from 1.5.55 to 1.5.55.1 - Added simplified WithConnectivityCheck() overloads that access options from builder.Options - Kept original overloads with explicit options parameter for backward compatibility - Updated tests to use the new simplified API - Updated release notes to document the improved API **API Improvement:** The new API eliminates redundant parameter passing: Before (1.5.55): ```csharp journal.WithConnectivityCheck(journalOptions); ``` After (1.5.55.1): ```csharp journal.WithConnectivityCheck(); // Options accessed from builder automatically ``` All 9 connectivity check tests pass with the new API.
1 parent d329fbc commit afc1aa2

File tree

4 files changed

+85
-9
lines changed

4 files changed

+85
-9
lines changed

src/Akka.Persistence.Azure.Hosting/AzureConnectivityCheckExtensions.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@ namespace Akka.Persistence.Azure.Hosting
1717
/// </summary>
1818
public static class AzureConnectivityCheckExtensions
1919
{
20+
/// <summary>
21+
/// Adds a connectivity check for the Azure Table Storage journal.
22+
/// This is a liveness check that proactively verifies database connectivity.
23+
/// </summary>
24+
/// <param name="builder">The journal builder</param>
25+
/// <param name="unHealthyStatus">The status to return when check fails. Defaults to Unhealthy.</param>
26+
/// <param name="name">Optional name for the health check. Defaults to "Akka.Persistence.Azure.Journal.{id}.Connectivity"</param>
27+
/// <param name="tags">Optional tags for the health check. Defaults to ["akka", "persistence", "azure", "journal", "connectivity"]</param>
28+
/// <returns>The journal builder for chaining</returns>
29+
/// <remarks>
30+
/// Requires Akka.Hosting 1.5.55.1 or later. Options are accessed from builder.Options automatically.
31+
/// </remarks>
32+
public static AkkaPersistenceJournalBuilder WithConnectivityCheck(
33+
this AkkaPersistenceJournalBuilder builder,
34+
HealthStatus unHealthyStatus = HealthStatus.Unhealthy,
35+
string? name = null,
36+
string[]? tags = null)
37+
{
38+
if (!(builder.Options is AzureTableStorageJournalOptions journalOptions))
39+
{
40+
throw new InvalidOperationException(
41+
"WithConnectivityCheck requires AzureTableStorageJournalOptions. " +
42+
"Ensure you're using this with WithAzureTableJournal() or pass options explicitly using the overload.");
43+
}
44+
45+
return WithConnectivityCheck(builder, journalOptions, unHealthyStatus, name, tags);
46+
}
47+
2048
/// <summary>
2149
/// Adds a connectivity check for the Azure Table Storage journal.
2250
/// This is a liveness check that proactively verifies database connectivity.
@@ -27,6 +55,10 @@ public static class AzureConnectivityCheckExtensions
2755
/// <param name="name">Optional name for the health check. Defaults to "Akka.Persistence.Azure.Journal.{id}.Connectivity"</param>
2856
/// <param name="tags">Optional tags for the health check. Defaults to ["akka", "persistence", "azure", "journal", "connectivity"]</param>
2957
/// <returns>The journal builder for chaining</returns>
58+
/// <remarks>
59+
/// This overload is provided for backward compatibility. Consider using the parameterless overload
60+
/// if you're on Akka.Hosting 1.5.55.1 or later.
61+
/// </remarks>
3062
public static AkkaPersistenceJournalBuilder WithConnectivityCheck(
3163
this AkkaPersistenceJournalBuilder builder,
3264
AzureTableStorageJournalOptions journalOptions,
@@ -60,6 +92,34 @@ public static AkkaPersistenceJournalBuilder WithConnectivityCheck(
6092
return builder.WithCustomHealthCheck(registration);
6193
}
6294

95+
/// <summary>
96+
/// Adds a connectivity check for the Azure Blob Storage snapshot store.
97+
/// This is a liveness check that proactively verifies database connectivity.
98+
/// </summary>
99+
/// <param name="builder">The snapshot builder</param>
100+
/// <param name="unHealthyStatus">The status to return when check fails. Defaults to Unhealthy.</param>
101+
/// <param name="name">Optional name for the health check. Defaults to "Akka.Persistence.Azure.SnapshotStore.{id}.Connectivity"</param>
102+
/// <param name="tags">Optional tags for the health check. Defaults to ["akka", "persistence", "azure", "snapshot-store", "connectivity"]</param>
103+
/// <returns>The snapshot builder for chaining</returns>
104+
/// <remarks>
105+
/// Requires Akka.Hosting 1.5.55.1 or later. Options are accessed from builder.Options automatically.
106+
/// </remarks>
107+
public static AkkaPersistenceSnapshotBuilder WithConnectivityCheck(
108+
this AkkaPersistenceSnapshotBuilder builder,
109+
HealthStatus unHealthyStatus = HealthStatus.Unhealthy,
110+
string? name = null,
111+
string[]? tags = null)
112+
{
113+
if (!(builder.Options is AzureBlobSnapshotOptions snapshotOptions))
114+
{
115+
throw new InvalidOperationException(
116+
"WithConnectivityCheck requires AzureBlobSnapshotOptions. " +
117+
"Ensure you're using this with WithAzureBlobsSnapshotStore() or pass options explicitly using the overload.");
118+
}
119+
120+
return WithConnectivityCheck(builder, snapshotOptions, unHealthyStatus, name, tags);
121+
}
122+
63123
/// <summary>
64124
/// Adds a connectivity check for the Azure Blob Storage snapshot store.
65125
/// This is a liveness check that proactively verifies database connectivity.
@@ -70,6 +130,10 @@ public static AkkaPersistenceJournalBuilder WithConnectivityCheck(
70130
/// <param name="name">Optional name for the health check. Defaults to "Akka.Persistence.Azure.SnapshotStore.{id}.Connectivity"</param>
71131
/// <param name="tags">Optional tags for the health check. Defaults to ["akka", "persistence", "azure", "snapshot-store", "connectivity"]</param>
72132
/// <returns>The snapshot builder for chaining</returns>
133+
/// <remarks>
134+
/// This overload is provided for backward compatibility. Consider using the parameterless overload
135+
/// if you're on Akka.Hosting 1.5.55.1 or later.
136+
/// </remarks>
73137
public static AkkaPersistenceSnapshotBuilder WithConnectivityCheck(
74138
this AkkaPersistenceSnapshotBuilder builder,
75139
AzureBlobSnapshotOptions snapshotOptions,

src/Akka.Persistence.Azure.Tests/Hosting/AzureConnectivityCheckSpec.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IService
5959
builder
6060
.WithAzureTableJournal(journalOptions, journal =>
6161
{
62-
journal.WithConnectivityCheck(journalOptions);
62+
// Using the new simplified API from Akka.Hosting 1.5.55.1
63+
journal.WithConnectivityCheck();
6364
})
6465
.WithAzureBlobsSnapshotStore(snapshotOptions, snapshot =>
6566
{
66-
snapshot.WithConnectivityCheck(snapshotOptions);
67+
// Using the new simplified API from Akka.Hosting 1.5.55.1
68+
snapshot.WithConnectivityCheck();
6769
});
6870
}
6971

@@ -219,11 +221,13 @@ protected override void ConfigureAkka(AkkaConfigurationBuilder builder, IService
219221
builder
220222
.WithAzureTableJournal(journalOptions, journal =>
221223
{
222-
journal.WithConnectivityCheck(journalOptions, HealthStatus.Degraded);
224+
// Using the new simplified API from Akka.Hosting 1.5.55.1
225+
journal.WithConnectivityCheck(HealthStatus.Degraded);
223226
})
224227
.WithAzureBlobsSnapshotStore(snapshotOptions, snapshot =>
225228
{
226-
snapshot.WithConnectivityCheck(snapshotOptions, HealthStatus.Degraded);
229+
// Using the new simplified API from Akka.Hosting 1.5.55.1
230+
snapshot.WithConnectivityCheck(HealthStatus.Degraded);
227231
});
228232
}
229233

src/Directory.Generated.props

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionPrefix>1.5.55</VersionPrefix>
44
<PackageReleaseNotes>* [Update Akka.NET v1.5.55](https://github.com/akkadotnet/akka.net/releases/tag/1.5.55)
5-
* [Update Akka.Hosting v1.5.55](https://github.com/akkadotnet/Akka.Hosting/releases/tag/1.5.55)
5+
* [Update Akka.Hosting v1.5.55.1](https://github.com/akkadotnet/Akka.Hosting/releases/tag/1.5.55.1)
66
* [Add connectivity health checks for Azure persistence backends](https://github.com/petabridge/Akka.Persistence.Azure/pull/TBD)
77

88
This release adds proactive connectivity health checks for Azure persistence backends, implementing the feature requested in [Akka.Hosting#678](https://github.com/akkadotnet/Akka.Hosting/issues/678).
@@ -11,6 +11,10 @@ This release adds proactive connectivity health checks for Azure persistence bac
1111

1212
Connectivity checks are now available for both Azure Table Storage journal and Azure Blob Storage snapshot store. These are opt-in health checks that proactively verify backend connectivity regardless of recent operation activity, helping detect database outages during idle periods.
1313

14+
**Improved API:**
15+
16+
With Akka.Hosting 1.5.55.1, the connectivity check API has been simplified. Options are now automatically accessed from the builder, eliminating redundant parameter passing.
17+
1418
**Usage Example:**
1519

1620
```csharp
@@ -31,14 +35,18 @@ var snapshotOptions = new AzureBlobSnapshotOptions(isDefault: true)
3135
builder
3236
.WithAzureTableJournal(journalOptions, journal =&gt;
3337
{
34-
journal.WithConnectivityCheck(journalOptions);
38+
journal.WithConnectivityCheck(); // Simplified API!
3539
})
3640
.WithAzureBlobsSnapshotStore(snapshotOptions, snapshot =&gt;
3741
{
38-
snapshot.WithConnectivityCheck(snapshotOptions);
42+
snapshot.WithConnectivityCheck(); // Simplified API!
3943
});
4044
```
4145

42-
The connectivity checks support all Azure SDK connection methods (connection string, ServiceUri + TokenCredential, and factory methods) and include proper tagging for filtering in health check endpoints.</PackageReleaseNotes>
46+
The connectivity checks support all Azure SDK connection methods (connection string, ServiceUri + TokenCredential, and factory methods) and include proper tagging for filtering in health check endpoints.
47+
48+
**Backward Compatibility:**
49+
50+
The old API signature (passing options explicitly) is still supported for backward compatibility with older versions of Akka.Hosting.</PackageReleaseNotes>
4351
</PropertyGroup>
4452
</Project>

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<AkkaVersion>1.5.55</AkkaVersion>
5-
<AkkaHostingVersion>1.5.55</AkkaHostingVersion>
5+
<AkkaHostingVersion>1.5.55.1</AkkaHostingVersion>
66
</PropertyGroup>
77
<!-- App dependencies -->
88
<ItemGroup>

0 commit comments

Comments
 (0)