Skip to content

Commit

Permalink
Realization of Persistence Query for InMemory Read Journal (#6409)
Browse files Browse the repository at this point in the history
* Started with InMemoryReadJournal.

* Update API Verify list

* Update csproj to use common.props and xunitsettings.props

* ICurrentEventsByPersistenceIdQuery and IEventsByPersistenceIdQuery has been implemented for InMemoryReadJournal.

* ICurrentEventsByTagQuery and IEventsByTagQuery has been implemented.

* ICurrentAllEventsQuery and IAllEventsQuery has been implemented.

* IPersistenceIds has been implemented.

* Filesystem dependent test has been fixed.

* Style and documentation fix.

* Moved from long to int part 1.

* Moved from long to int part 2.

* Move from long to int part 3.

* Refactoring.

* Refactoring.

* Update API Verify list

* Revert changes to TCK and fix unit tests

* Remove obsolete query messages

* Update Akka.Persistence.Query.InMemory.Tests.csproj

---------

Co-authored-by: Gregorius Soedharmo <arkatufus@yahoo.com>
Co-authored-by: Aaron Stannard <aaron@petabridge.com>
  • Loading branch information
3 people authored Mar 7, 2023
1 parent 149cc05 commit d703632
Show file tree
Hide file tree
Showing 29 changed files with 2,311 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/Akka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSender", "examples\Cl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersistenceExample", "examples\PersistenceExample\PersistenceExample.csproj", "{4022147A-4F95-4A04-BE09-01B7952BBDD9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.Query.InMemory", "contrib\persistence\Akka.Persistence.Query.InMemory\Akka.Persistence.Query.InMemory.csproj", "{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.Query.InMemory.Tests", "contrib\persistence\Akka.Persistence.Query.InMemory.Tests\Akka.Persistence.Query.InMemory.Tests.csproj", "{407DD6E2-F274-4773-BA5E-43541D5C8D0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1265,6 +1269,30 @@ Global
{4022147A-4F95-4A04-BE09-01B7952BBDD9}.Release|x64.Build.0 = Release|Any CPU
{4022147A-4F95-4A04-BE09-01B7952BBDD9}.Release|x86.ActiveCfg = Release|Any CPU
{4022147A-4F95-4A04-BE09-01B7952BBDD9}.Release|x86.Build.0 = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|x64.ActiveCfg = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|x64.Build.0 = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|x86.ActiveCfg = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Debug|x86.Build.0 = Debug|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|Any CPU.Build.0 = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|x64.ActiveCfg = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|x64.Build.0 = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|x86.ActiveCfg = Release|Any CPU
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F}.Release|x86.Build.0 = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|x64.ActiveCfg = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|x64.Build.0 = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|x86.ActiveCfg = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Debug|x86.Build.0 = Debug|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|Any CPU.Build.0 = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|x64.ActiveCfg = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|x64.Build.0 = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|x86.ActiveCfg = Release|Any CPU
{407DD6E2-F274-4773-BA5E-43541D5C8D0F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1385,6 +1413,8 @@ Global
{09CFD060-C7DC-49CC-A6C6-D3FE341A7320} = {51C887A7-7A69-43E2-9BE2-17016E2D8476}
{A5392607-15B8-4869-BB20-FAAD4D09E08B} = {51C887A7-7A69-43E2-9BE2-17016E2D8476}
{4022147A-4F95-4A04-BE09-01B7952BBDD9} = {A640E39E-F45C-4AE9-AABF-7F1432D357DA}
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
{407DD6E2-F274-4773-BA5E-43541D5C8D0F} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03AD8E21-7507-4E68-A4E9-F4A7E7273164}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\xunitSettings.props" />

<PropertyGroup>
<AssemblyTitle>Akka.Persistence.Query.InMemory.Tests</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetCoreTestVersion);$(NetTestVersion)</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Persistence.TCK\Akka.Persistence.TCK.csproj" />
<ProjectReference Include="..\Akka.Persistence.Query.InMemory\Akka.Persistence.Query.InMemory.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryAllEventsSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryAllEventsSpec : AllEventsSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.query.journal.inmem.refresh-interval = 1s
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryAllEventsSpec(ITestOutputHelper output) : base(Config(), nameof(InMemoryAllEventsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryCurrentAllEventsSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryCurrentAllEventsSpec : CurrentAllEventsSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.query.journal.inmem.refresh-interval = 1s
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryCurrentAllEventsSpec(ITestOutputHelper output) : base(Config(), nameof(InMemoryCurrentAllEventsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryCurrentEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryCurrentEventsByPersistenceIdSpec : CurrentEventsByPersistenceIdSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryCurrentEventsByPersistenceIdSpec(ITestOutputHelper output) :
base(Config(), nameof(InMemoryCurrentPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryCurrentEventsByTagSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryCurrentEventsByTagSpec : CurrentEventsByTagSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""
akka.persistence.journal.inmem {{
event-adapters {{
color-tagger = ""Akka.Persistence.TCK.Query.ColorFruitTagger, Akka.Persistence.TCK""
}}
event-adapter-bindings = {{
""System.String"" = color-tagger
}}
}}")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryCurrentEventsByTagSpec(ITestOutputHelper output) :
base(Config(), nameof(InMemoryCurrentPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryCurrentPersistenceIdsSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryCurrentPersistenceIdsSpec : CurrentPersistenceIdsSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryCurrentPersistenceIdsSpec(ITestOutputHelper output) :
base(Config(), nameof(InMemoryCurrentPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryEventsByPersistenceIdSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryEventsByPersistenceIdSpec : EventsByPersistenceIdSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.query.journal.inmem.refresh-interval = 1s
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryEventsByPersistenceIdSpec(ITestOutputHelper output) :
base(Config(), nameof(InMemoryCurrentPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryEventsByTagSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryEventsByTagSpec : EventsByTagSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""
akka.persistence.journal.inmem {{
event-adapters {{
color-tagger = ""Akka.Persistence.TCK.Query.ColorFruitTagger, Akka.Persistence.TCK""
}}
event-adapter-bindings = {{
""System.String"" = color-tagger
}}
}}")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());

public InMemoryEventsByTagSpec(ITestOutputHelper output) :
base(Config(), nameof(InMemoryCurrentPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// //-----------------------------------------------------------------------
// // <copyright file="InMemoryPersistenceIdsSpec.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2023 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------

using System;
using Akka.Configuration;
using Akka.Persistence.TCK.Query;
using Xunit.Abstractions;

namespace Akka.Persistence.Query.InMemory.Tests
{
public class InMemoryPersistenceIdsSpec : PersistenceIdsSpec
{
private static Config Config() => ConfigurationFactory.ParseString($@"
akka.loglevel = INFO
akka.persistence.query.journal.inmem.refresh-interval = 1s
akka.persistence.journal.plugin = ""akka.persistence.journal.inmem""
akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.inmem""")
.WithFallback(InMemoryReadJournal.DefaultConfiguration());


public InMemoryPersistenceIdsSpec(ITestOutputHelper output) : base(Config(), nameof(InMemoryPersistenceIdsSpec), output)
{
ReadJournal = Sys.ReadJournalFor<InMemoryReadJournal>(InMemoryReadJournal.Identifier);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />

<PropertyGroup>
<AssemblyTitle>Akka.Persistence.Query.InMemory</AssemblyTitle>
<Description>Akka.NET Persistence Query implementation for InMemory Journal.</Description>
<TargetFrameworks>$(NetStandardLibVersion);$(NetLibVersion)</TargetFrameworks>
<PackageTags>$(AkkaPackageTags);persistence;eventsource;sql;reactive;streams</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\Akka.Persistence.Query\Akka.Persistence.Query.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="reference.conf" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>

</Project>
Loading

0 comments on commit d703632

Please sign in to comment.