Skip to content

Native AOT: register the plugin through Akka.Persistence.Hosting (Akka.NET 1.6) #563

Open

Description

@Aaronontheweb

Part of the Native AOT epic: akkadotnet/akka.net#8753. Starts after akka.net #8738 and #8739 merge and Akka.NET 1.6 ships.

With Akka.DynamicTypeLoading off, Akka.NET loads persistence types from the Hosting options, not from HOCON type names. This plugin opts in by changing the base class of its Hosting options. User code does not change.

Steps

  1. Move to Akka.NET 1.6 and fix the breaks the spike found:

    • Remove the System.Linq.Async package. It causes CS0121 against the net10 BCL.
    • Add new on ClusterShardingSpec InitializeAsync / DisposeAsync (CS0114).
    • Raise LangVersion from 8.
  2. Change the options base classes: the journal options to JournalOptions<AzureTableStorageJournal, ...> and the snapshot options to SnapshotOptions<AzureBlobSnapshotStore>. Use the two-argument journal form with the read journal provider. Override ReadJournalPluginId only if the read journal path is not akka.persistence.query.journal.{Identifier}. Check the path against the plugin's HOCON.

  3. Remove uses of JournalOptions.Adapters, if any.

  4. Route the Setup-based overloads through typed options. These two bypass WithJournal / WithSnapshot today, so nothing registers the types with the switch off:

    • WithAzureTableJournal(AzureTableStorageJournalSetup setup, ...): it calls WithJournal only when a journalBuilder is passed.
    • WithAzureBlobsSnapshotStore(AzureBlobSnapshotSetup setup): it never calls WithSnapshot.

    Call WithJournal / WithSnapshot every time with a typed options object. The Setup values must still win over the options defaults.

  5. Keep the read journal's default HOCON in config from the Hosting extension.

  6. Check the plugin HOCON for serializers named by type. Register them with WithCustomSerializer.

  7. Run the Hosting tests with the switch off. Add tests for both Setup-based overloads.

    <RuntimeHostConfigurationOption Include="Akka.DynamicTypeLoading" Value="false" />

Test notes

  • Spike (earlier API): 18 of 19 Hosting tests passed with the switch off. The 1 failure was a test payload type with no serializer. Register it in code. This is a test-side fix.
  • TestKit-based suites work with the switch off since akka.net #8754 (merged).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions