-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom persistence provider documentation (#5516)
* Add initial documentation proposal * Add custom provider sample project for documentation code linking * Fix linter error * Improve code formatting so it can be read better in the documentation * Documentation improvements * Add TODO tags for things that still need to be written * Use code linking for code examples, linking to the sample project * Improve WriteMessagesAsync documentation, shuffle paragraphs around for readability, add headers to separate the explanations, change long paragraphs into bullet points * Rename file name to custom-persistence-provider, add docs to TOC * Fix linter problems * Add missing PostStop method to SqliteJournal * Update documentation * Add SnapshotStore, extension, and unit testing documentation. * Fix linter errors * Fix bad word wrapping Co-authored-by: Aaron Stannard <aaron@petabridge.com>
- Loading branch information
1 parent
185559a
commit a5ef30f
Showing
14 changed files
with
1,850 additions
and
0 deletions.
There are no files selected for viewing
466 changes: 466 additions & 0 deletions
466
docs/articles/persistence/custom-persistence-provider.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/examples/Akka.Persistence.Custom.Tests/Akka.Persistence.Custom.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\common.props" /> | ||
<Import Project="..\..\xunitSettings.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" /> | ||
<PackageReference Include="xunit" Version="$(XunitVersion)" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\core\Akka.Persistence.TCK\Akka.Persistence.TCK.csproj" /> | ||
<ProjectReference Include="..\Akka.Persistence.Custom\Akka.Persistence.Custom.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
52 changes: 52 additions & 0 deletions
52
src/examples/Akka.Persistence.Custom.Tests/SqliteJournalSerializationSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// //----------------------------------------------------------------------- | ||
// // <copyright file="SqliteJournalSerializationSpec.cs" company="Akka.NET Project"> | ||
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// // </copyright> | ||
// //----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Configuration; | ||
using Akka.Persistence.TCK.Serialization; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Custom.Tests | ||
{ | ||
public class SqliteJournalSerializationSpec : JournalSerializationSpec | ||
{ | ||
public SqliteJournalSerializationSpec(ITestOutputHelper output) | ||
: base(CreateSpecConfig("Filename=file:memdb-journal-" + Guid.NewGuid() + ".db"), nameof(SqliteJournalSerializationSpec), output) | ||
{ | ||
} | ||
|
||
private static Config CreateSpecConfig(string connectionString) | ||
{ | ||
return ConfigurationFactory.ParseString(@" | ||
akka.persistence { | ||
publish-plugin-commands = on | ||
journal { | ||
plugin = ""akka.persistence.journal.custom-sqlite"" | ||
custom-sqlite { | ||
event-adapters { | ||
custom-adapter = ""Akka.Persistence.TCK.Serialization.TestJournal+MyWriteAdapter, Akka.Persistence.TCK"" | ||
} | ||
event-adapter-bindings = { | ||
""Akka.Persistence.TCK.Serialization.TestJournal+MyPayload3, Akka.Persistence.TCK"" = custom-adapter | ||
} | ||
class = ""Akka.Persistence.Custom.Journal.SqliteJournal, Akka.Persistence.Custom"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
auto-initialize = on | ||
connection-string = """ + connectionString + @""" | ||
} | ||
} | ||
}"); | ||
} | ||
|
||
|
||
[Fact(Skip = "SQLite plugin does not support EventAdapter.Manifest")] | ||
public override void Journal_should_serialize_Persistent_with_EventAdapter_manifest() | ||
{ | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/examples/Akka.Persistence.Custom.Tests/SqliteJournalSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// //----------------------------------------------------------------------- | ||
// // <copyright file="SqliteJournalSpec.cs" company="Akka.NET Project"> | ||
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// // </copyright> | ||
// //----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Data.Common; | ||
using System.Threading.Tasks; | ||
using Akka.Configuration; | ||
using Akka.Persistence.TCK.Journal; | ||
using Akka.Util.Internal; | ||
using Microsoft.Data.Sqlite; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Custom.Tests | ||
{ | ||
public class SqliteJournalSpec : JournalSpec | ||
{ | ||
public SqliteJournalSpec(ITestOutputHelper output) | ||
: base(CreateSpecConfig("Filename=file:memdb-journal-" + Guid.NewGuid() + ".db"), nameof(SqliteJournalSpec), output) | ||
{ | ||
SqlitePersistence.Get(Sys); | ||
|
||
Initialize(); | ||
} | ||
|
||
protected override bool SupportsSerialization => false; | ||
|
||
private static Config CreateSpecConfig(string connectionString) | ||
{ | ||
return ConfigurationFactory.ParseString(@" | ||
akka.persistence { | ||
publish-plugin-commands = on | ||
journal { | ||
plugin = ""akka.persistence.journal.custom-sqlite"" | ||
custom-sqlite { | ||
class = ""Akka.Persistence.Custom.Journal.SqliteJournal, Akka.Persistence.Custom"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
auto-initialize = on | ||
connection-string = """ + connectionString + @""" | ||
} | ||
} | ||
}"); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/examples/Akka.Persistence.Custom.Tests/SqliteSnapshotStoreSerializationSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// //----------------------------------------------------------------------- | ||
// // <copyright file="SqliteSnapshotStoreSerializationSpec.cs" company="Akka.NET Project"> | ||
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// // </copyright> | ||
// //----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Configuration; | ||
using Akka.Persistence.TCK.Serialization; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Custom.Tests | ||
{ | ||
public class SqliteSnapshotStoreSerializationSpec: SnapshotStoreSerializationSpec | ||
{ | ||
public SqliteSnapshotStoreSerializationSpec(ITestOutputHelper output) | ||
: base(CreateSpecConfig("Filename=file:serialization-snapshot-" + Guid.NewGuid() + ".db"), "SqliteSnapshotStoreSerializationSpec", output) | ||
{ | ||
} | ||
|
||
private static Config CreateSpecConfig(string connectionString) | ||
{ | ||
return ConfigurationFactory.ParseString(@" | ||
akka.persistence { | ||
publish-plugin-commands = on | ||
snapshot-store { | ||
plugin = ""akka.persistence.snapshot-store.custom-sqlite"" | ||
custom-sqlite { | ||
class = ""Akka.Persistence.Custom.Snapshot.SqliteSnapshotStore, Akka.Persistence.Custom"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
auto-initialize = on | ||
connection-string = """ + connectionString + @""" | ||
} | ||
} | ||
}"); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/examples/Akka.Persistence.Custom.Tests/SqliteSnapshotStoreSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// //----------------------------------------------------------------------- | ||
// // <copyright file="SqliteSnapshotStoreSpec.cs" company="Akka.NET Project"> | ||
// // Copyright (C) 2009-2022 Lightbend Inc. <http://www.lightbend.com> | ||
// // Copyright (C) 2013-2022 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// // </copyright> | ||
// //----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Configuration; | ||
using Akka.Persistence.TCK.Snapshot; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Persistence.Custom.Tests | ||
{ | ||
public class SqliteSnapshotStoreSpec : SnapshotStoreSpec | ||
{ | ||
public SqliteSnapshotStoreSpec(ITestOutputHelper output) | ||
: base(CreateSpecConfig("Filename=file:memdb-snapshot-" + Guid.NewGuid() + ".db"), "SqliteSnapshotStoreSpec", output) | ||
{ | ||
SqlitePersistence.Get(Sys); | ||
|
||
Initialize(); | ||
} | ||
|
||
private static Config CreateSpecConfig(string connectionString) | ||
{ | ||
return ConfigurationFactory.ParseString(@" | ||
akka.persistence { | ||
publish-plugin-commands = on | ||
snapshot-store { | ||
plugin = ""akka.persistence.snapshot-store.custom-sqlite"" | ||
custom-sqlite { | ||
class = ""Akka.Persistence.Custom.Snapshot.SqliteSnapshotStore, Akka.Persistence.Custom"" | ||
plugin-dispatcher = ""akka.actor.default-dispatcher"" | ||
auto-initialize = on | ||
connection-string = """ + connectionString + @""" | ||
} | ||
} | ||
}"); | ||
} | ||
|
||
protected override bool SupportsSerialization => true; | ||
}} |
20 changes: 20 additions & 0 deletions
20
src/examples/Akka.Persistence.Custom/Akka.Persistence.Custom.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<LangVersion>8.0</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Data.SQLite" Version="5.0.11" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\core\Akka.Persistence\Akka.Persistence.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="sqlite.conf" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.