Skip to content

Commit

Permalink
Marten ProviderUpdate and Persistence provider test (#2031)
Browse files Browse the repository at this point in the history
* feat: Update Marten package version to 6.0.2

- Updated the Marten package version from 4.3.1 to 6.0.2 in the project file.
- Changed the access modifier of the `Event` and `Snapshot` classes from internal to public in the `Proto.Persistence.Marten` namespace.
- Replaced calls to `_store.OpenSession()` with `_store.IdentitySession()` in the `MartenProvider` class for consistency.
- Added new test cases for different providers (InMemory and Marten) in the `ExamplePersistentActorTests` class:
    - EventsAreSavedToPersistence
    - SnapshotsAreSavedToPersistence
    - EventsCanBeDeleted
    - SnapshotsCanBeDeleted
    - GivenEventsOnly_StateIsRestoredFromEvents
    - GivenASnapshotOnly_StateIsRestoredFromTheSnapshot
    - GivenEventsThenASnapshot_StateShouldBeRestoredFromTheSnapshot
    - GivenASnapshotAndSubsequentEvents_StateShouldBeRestoredFromSnapshotAndSubsequentEvents
    - GivenMultipleSnapshots_StateIsRestoredFromMostRecentSnapshot

* Refactor tests to use Sqlite provider

* Add support for additional persistence providers

This commit adds support for the following persistence providers:
- Couchbase
- DynamoDB
- MongoDB
- RavenDB
- SQL Server

It also includes changes to the ExamplePersistentActorTests class to test the functionality of these new providers.

* removed providers

---------

Co-authored-by: Giuseppe Patanè <[email protected]>
  • Loading branch information
GiuseppePatane and vivaticket-gpatane authored Aug 29, 2023
1 parent d77dbaa commit f3e874f
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/Proto.Persistence.Marten/Event.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Proto.Persistence.Marten;

internal class Event
public class Event
{
public Event(string actorName, long index, object data)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Proto.Persistence.Marten/MartenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public MartenProvider(IDocumentStore store)

public async Task<long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback)
{
var session = _store.OpenSession();
var session = _store.IdentitySession();
await using var _ = session.ConfigureAwait(false);

var events = await session.Query<Event>()
Expand All @@ -35,7 +35,7 @@ public async Task<long> GetEventsAsync(string actorName, long indexStart, long i

public async Task<(object Snapshot, long Index)> GetSnapshotAsync(string actorName)
{
var session = _store.OpenSession();
var session = _store.IdentitySession();
await using var _ = session.ConfigureAwait(false);

var snapshot = await session.Query<Snapshot>()
Expand All @@ -48,7 +48,7 @@ public async Task<long> GetEventsAsync(string actorName, long indexStart, long i

public async Task<long> PersistEventAsync(string actorName, long index, object @event)
{
using var session = _store.OpenSession();
var session = _store.IdentitySession();

session.Store(new Event(actorName, index, @event));

Expand All @@ -59,7 +59,7 @@ public async Task<long> PersistEventAsync(string actorName, long index, object @

public async Task PersistSnapshotAsync(string actorName, long index, object snapshot)
{
using var session = _store.OpenSession();
var session = _store.IdentitySession();

session.Store(new Snapshot(actorName, index, snapshot));

Expand All @@ -68,7 +68,7 @@ public async Task PersistSnapshotAsync(string actorName, long index, object snap

public async Task DeleteEventsAsync(string actorName, long inclusiveToIndex)
{
using var session = _store.OpenSession();
var session = _store.IdentitySession();

session.DeleteWhere<Event>(x =>
x.ActorName == actorName &&
Expand All @@ -80,7 +80,7 @@ public async Task DeleteEventsAsync(string actorName, long inclusiveToIndex)

public async Task DeleteSnapshotsAsync(string actorName, long inclusiveToIndex)
{
using var session = _store.OpenSession();
var session = _store.IdentitySession();

session.DeleteWhere<Snapshot>(x =>
x.ActorName == actorName &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Marten" Version="4.3.1" />
<PackageReference Include="Marten" Version="6.0.2" />

</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Persistence.Marten/Snapshot.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Proto.Persistence.Marten;

internal class Snapshot
public class Snapshot
{
public Snapshot(string actorName, long index, object data)
{
Expand Down
Loading

0 comments on commit f3e874f

Please sign in to comment.