Skip to content

Conversation

@Aaronontheweb
Copy link
Member

Summary

This PR exposes the JournalOptions and SnapshotOptions instances in their respective builder classes, eliminating the need for plugin extension methods to require options as explicit parameters.

Changes

  • Added JournalOptions? Options property to AkkaPersistenceJournalBuilder
  • Added SnapshotOptions? Options property to AkkaPersistenceSnapshotBuilder
  • Added new constructors that accept options parameters
  • Updated WithJournal() and WithSnapshot() methods to pass options to builders
  • Maintained full backward compatibility via nullable Options and legacy constructors

Problem Solved

Previously, connectivity check extensions and other plugin-specific methods needed to accept options redundantly:

// Before - options passed twice
builder.WithAzureTableJournal(journalOptions, journal =>
{
    journal.WithConnectivityCheck(journalOptions); // Redundant!
});

After this fix:

// After - options accessible from builder
builder.WithAzureTableJournal(journalOptions, journal =>
{
    journal.WithConnectivityCheck(); // Options available via journal.Options
});

Testing

  • Added comprehensive test suite (BuilderOptionsAccessSpec) with 6 tests covering:
    • Journal builder options exposure
    • Snapshot builder options exposure
    • Both builders in WithJournalAndSnapshot
    • Backward compatibility with parameterless constructor
    • Legacy code paths (WithInMemoryJournal)
    • Extension method access to connection details
  • All tests passing ✅
  • API approval tests updated and passing ✅

Backward Compatibility

✅ Fully backward compatible:

  • Original parameterless constructors preserved
  • Options property is nullable for legacy usage
  • Existing code continues to work unchanged

Related Issues

Resolves #690

Added Options property to AkkaPersistenceJournalBuilder and
AkkaPersistenceSnapshotBuilder, allowing extension methods to access
configuration details without requiring options as explicit parameters.

This resolves the API design issue where connectivity check extensions
and other plugin-specific methods needed options passed redundantly.

Changes:
- Added JournalOptions? Options property to AkkaPersistenceJournalBuilder
- Added SnapshotOptions? Options property to AkkaPersistenceSnapshotBuilder
- Added new constructors accepting options parameters
- Updated WithJournal() and WithSnapshot() to pass options to builders
- Maintained backward compatibility via nullable Options and legacy constructors
- Added comprehensive test suite (BuilderOptionsAccessSpec) with 6 passing tests
- Updated API approval baseline

Resolves akkadotnet#690
@Aaronontheweb Aaronontheweb merged commit fc3b5c6 into akkadotnet:dev Oct 27, 2025
2 checks passed
@Arkatufus
Copy link
Contributor

LGTM

Aaronontheweb added a commit to Aaronontheweb/Akka.Persistence.Azure that referenced this pull request Oct 27, 2025
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.
Aaronontheweb added a commit to petabridge/Akka.Persistence.Azure that referenced this pull request Oct 27, 2025
* Add connectivity health checks for Azure persistence backends

Implements proactive connectivity health checks for both Azure Table Storage journal and Azure Blob Storage snapshot store, addressing akkadotnet/Akka.Hosting#678.

Key additions:
- AzureConnectivityCheckExtensions: WithConnectivityCheck() methods for journal and snapshot store builders
- AzureTableJournalConnectivityCheck: Health check implementation using TableServiceClient.GetPropertiesAsync()
- AzureBlobSnapshotStoreConnectivityCheck: Health check implementation using BlobServiceClient.GetPropertiesAsync()
- Comprehensive test suite with 9 tests covering valid and invalid connection scenarios

The implementation follows the same pattern as Redis, SQL, and MongoDB plugins, supporting all Azure SDK connection methods (connection string, ServiceUri + TokenCredential, and factory methods). Health checks are opt-in via .WithConnectivityCheck() and include proper tagging for filtering.

Also upgrades Akka.NET and Akka.Hosting to 1.5.55 to utilize the new WithCustomHealthCheck API.

* Update RELEASE_NOTES.md for v1.5.55

Add release notes documenting the new connectivity health check features and upgrade to Akka.NET/Akka.Hosting 1.5.55.

* 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.

* Add comprehensive health check documentation

Updated RELEASE_NOTES.md and README.md to document the new connectivity
health check feature introduced in v1.5.55.

**RELEASE_NOTES.md Changes:**
- Updated Akka.Hosting version reference from 1.5.55 to 1.5.55.1
- Added "Improved API" section explaining simplified connectivity check API
- Updated usage example to show new parameterless WithConnectivityCheck() method
- Added backward compatibility note

**README.md Changes:**
- Expanded Health Checks section with two subsections:
  - Standard Health Checks: existing WithHealthCheck() functionality
  - Connectivity Health Checks: new WithConnectivityCheck() functionality
- Added usage examples showing both individual and combined health check usage
- Documented support for all Azure SDK connection methods
- Included code examples demonstrating the simplified Akka.Hosting 1.5.55.1 API

The connectivity checks are proactive health checks that verify backend
connectivity regardless of recent operation activity, helping detect
database outages during idle periods.

* Fix Azure client creation priority order in connectivity checks

Fixed critical bug where health check client creation used incorrect
priority order (Factory > ConnectionString > Credential) instead of the
correct order (Factory > Credential > ConnectionString).

**Changes:**

1. Added `CreateTableServiceClient()` to `AzureTableStorageJournalSettings`
   - Centralizes client creation logic
   - Documents priority order: Factory > ServiceUri+Credential > ConnectionString
   - Eliminates code duplication

2. Added `CreateBlobServiceClient()` to `AzureBlobSnapshotStoreSettings`
   - Centralizes client creation logic
   - Documents priority order: Factory > ServiceUri+Credential > ConnectionString
   - Eliminates code duplication

3. Fixed `AzureTableJournalConnectivityCheck`
   - Corrected priority order to match core journal implementation
   - Added comment documenting correct order

4. Fixed `AzureBlobSnapshotStoreConnectivityCheck`
   - Corrected priority order to match core snapshot store implementation
   - Added comment documenting correct order

**Impact:**

This fixes potential issues where users configure both ConnectionString and
ServiceUri+Credential - previously health checks would use ConnectionString
while the actual plugins would use ServiceUri+Credential, leading to health
checks testing the wrong backend.

All 9 connectivity check tests pass with corrected priority order.

* Fix health check test expectations for correct key casing

Updated test assertions in AzurePersistenceHealthCheckSpec to match the actual health check keys used by Akka.Hosting:
- Changed "Akka.Persistence.Journal.azure-table" to "akka.persistence.journal.azure-table"
- Changed "Akka.Persistence.SnapshotStore.azure-blob-store" to "akka.persistence.snapshot-store.azure-blob-store"

The health check keys are generated by the Akka.Hosting framework using lowercase HOCON-style paths. Test expectations were using incorrect Pascal case and inconsistent naming ("SnapshotStore" vs "snapshot-store").

* Approve new public API surface for connectivity health checks

Updated API approval snapshots to include new public APIs:
- AzureBlobSnapshotStoreConnectivityCheck class
- AzureTableJournalConnectivityCheck class
- AzureConnectivityCheckExtensions class with WithConnectivityCheck extension methods
- CreateBlobServiceClient() factory method in AzureBlobSnapshotStoreSettings
- CreateTableServiceClient() factory method in AzureTableStorageJournalSettings

These additions provide proactive connectivity health checks for Azure persistence backends and centralize client creation logic to eliminate code duplication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Improvement: Store options reference in AkkaPersistenceJournalBuilder and AkkaPersistenceSnapshotBuilder

2 participants