Skip to content

Conversation

@Aaronontheweb
Copy link
Member

This PR updates the connectivity health check extension methods to use the simplified Akka.Hosting 1.5.55.1 API pattern, eliminating redundant parameter passing.

Changes

API Improvements

  • Simplified API: Options are now automatically accessed from builder.Options
  • Backward Compatibility: Previous API remains functional but marked as [Obsolete]
  • Enhanced Flexibility: Tags parameter now accepts IEnumerable<string> instead of string[]

Implementation Details

  • Updated MongoDbConnectivityCheckExtensions.cs with new simplified overloads for:
    • Journal connectivity checks
    • Standard snapshot store connectivity checks
    • GridFS snapshot store connectivity checks
  • Added using System.Collections.Generic; for IEnumerable<string> support
  • Upgraded Akka.Hosting dependency from 1.5.55 to 1.5.55.1
  • Updated RELEASE_NOTES.md with v1.5.55.1 entry

API Comparison

New Simplified API (Recommended):

journalBuilder: journal =>
{
    journal.WithConnectivityCheck(); // Options automatically accessed from builder
}

Previous API (Still Supported):

journalBuilder: journal =>
{
    journal.WithConnectivityCheck(journalOptions); // Explicit parameter passing
}

Special Handling

The snapshot store simplified API intelligently detects whether the configuration uses standard MongoDB snapshots or GridFS snapshots, handling both scenarios automatically:

if (builder.Options is MongoDbSnapshotOptions snapshotOptions)
{
    // Handle standard snapshot store
}
else if (builder.Options is MongoDbGridFsSnapshotOptions gridFsOptions)
{
    // Handle GridFS snapshot store
}

Benefits

  • Cleaner, more intuitive API
  • Reduces potential for configuration errors
  • Maintains full backward compatibility
  • Follows Akka.Hosting 1.5.55.1 patterns
  • Automatic detection of snapshot store type

Testing

  • Build succeeds with no errors
  • Pattern consistent with Akka.Persistence.Linq2Db implementation
  • Legacy API continues to work with obsolete warnings

Related to akkadotnet/Akka.Hosting#1.5.55.1

This update eliminates redundant parameter passing by automatically accessing
options from builder.Options, making the API cleaner and less error-prone.

New simplified API:
- journal.WithConnectivityCheck() - no parameters needed
- Options automatically accessed from builder.Options

Previous API remains functional but marked as [Obsolete] for backward compatibility.

Changes:
- Update MongoDbConnectivityCheckExtensions.cs with simplified API pattern
- Add IEnumerable<string> support for customizable tags parameter
- Mark legacy API overloads as [Obsolete]
- Upgrade Akka.Hosting from 1.5.55 to 1.5.55.1
- Update RELEASE_NOTES.md with v1.5.55.1 entry
Tests validate the new Akka.Hosting 1.5.55.1 simplified API that automatically
accesses options from builder.Options.

Test coverage includes:
- Journal connectivity check registration
- Snapshot store connectivity check registration
- Custom health status configuration
- Custom name configuration
- Custom tags configuration
- Validation that missing connection strings throw appropriate exceptions

The simplified API automatically detects whether MongoDbSnapshotOptions or
MongoDbGridFsSnapshotOptions is being used, providing seamless support for
both standard and GridFS snapshot stores without requiring different methods.

These tests complement the existing unit tests for connectivity check classes
by validating the extension method integration points.
…osting test infrastructure

Fixed failing tests by switching from manual ServiceCollection instantiation to inheriting from Akka.Hosting.TestKit.TestKit. Tests now properly use the Akka.Hosting infrastructure to register health checks and validate them using the public HealthCheckService API instead of reflection.

Changes:
- Inherit from Akka.Hosting.TestKit.TestKit base class
- Use DatabaseFixture for MongoDB connection strings
- Override ConfigureServices() and ConfigureAkka() methods
- Changed test methods from void to async Task
- Use await healthCheckService.CheckHealthAsync() to get health report
- Validate health checks via healthReport.Entries collection instead of reflection
- Added CustomConnectivityCheckConfigSpec test class to validate custom configuration options
@Aaronontheweb Aaronontheweb merged commit 3062fd6 into akkadotnet:dev Oct 29, 2025
2 checks passed
@Aaronontheweb Aaronontheweb deleted the feature/simplified-connectivity-check-api branch October 29, 2025 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant