Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.0-beta2 Release #100

Merged
merged 3 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#### 1.4.0-beta1 October 30 2019 ####
Beta release of Akka.Persistence.MongoDB which implements the [new standardized Akka.Persistence serialization paradigm](https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/72) going forward. Has full backwards compatibility for reading events which were written in 1.3.[0-14] style serialization.
#### 1.4.0-beta2 October 31 2019 ####
Fixed [an issue with Snapshot serialization in v1.4.0-beta1](https://github.com/akkadotnet/Akka.Persistence.MongoDB/pull/98)
6 changes: 3 additions & 3 deletions src/Akka.Persistence.MongoDb/Journal/MongoDbJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,16 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)

private Persistent ToPersistenceRepresentation(JournalEntry entry, IActorRef sender)
{
int? serializerId = null;
Type type = null;

var legacy = entry.SerializerId.HasValue || !string.IsNullOrEmpty(entry.Manifest);
if (!legacy)
{
var ser = _serialization.FindSerializerForType(typeof(Persistent));
return ser.FromBinary<Persistent>((byte[]) entry.Payload);
}

int? serializerId = null;
Type type = null;

// legacy serialization
if (!entry.SerializerId.HasValue && !string.IsNullOrEmpty(entry.Manifest))
type = Type.GetType(entry.Manifest, true);
Expand Down
33 changes: 22 additions & 11 deletions src/Akka.Persistence.MongoDb/Snapshot/MongoDbSnapshotStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,44 @@ private SnapshotEntry ToSnapshotEntry(SnapshotMetadata metadata, object snapshot

private SelectedSnapshot ToSelectedSnapshot(SnapshotEntry entry)
{
var legacy = entry.SerializerId.HasValue || !string.IsNullOrEmpty(entry.Manifest);

if (!legacy)
{
var ser = _serialization.FindSerializerForType(typeof(Serialization.Snapshot));
var snapshot = ser.FromBinary<Serialization.Snapshot>((byte[])entry.Snapshot);
return new SelectedSnapshot(new SnapshotMetadata(entry.PersistenceId, entry.SequenceNr), snapshot.Data);
}

int? serializerId = null;
Type type = null;

// legacy serialization
if (!entry.SerializerId.HasValue && !string.IsNullOrEmpty(entry.Manifest))
type = Type.GetType(entry.Manifest, true);
else
serializerId = entry.SerializerId;

if (entry.Snapshot is byte[] bytes)
{
Type type = null;

if (string.IsNullOrEmpty(entry.Manifest))
type = Type.GetType(entry.Manifest, throwOnError: true);
object deserialized;

object dSnapshot;
if (entry.SerializerId.HasValue)
if (serializerId.HasValue)
{
dSnapshot = type == null ? _serialization.Deserialize(bytes, entry.SerializerId.Value, entry.Manifest)
: _serialization.Deserialize(bytes, entry.SerializerId.Value, type);
deserialized = _serialization.Deserialize(bytes, serializerId.Value, entry.Manifest);
}
else
{
var deserializer = _serialization.FindSerializerForType(type);
dSnapshot = deserializer.FromBinary(bytes, type);
deserialized = deserializer.FromBinary(bytes, type);
}

if (dSnapshot is Serialization.Snapshot snap)
if (deserialized is Serialization.Snapshot snap)
return new SelectedSnapshot(
new SnapshotMetadata(entry.PersistenceId, entry.SequenceNr, new DateTime(entry.Timestamp)), snap.Data);

return new SelectedSnapshot(
new SnapshotMetadata(entry.PersistenceId, entry.SequenceNr, new DateTime(entry.Timestamp)), dSnapshot);
new SnapshotMetadata(entry.PersistenceId, entry.SequenceNr, new DateTime(entry.Timestamp)), deserialized);
}

// backwards compat - loaded an old snapshot using BSON serialization. No need to deserialize via Akka.NET
Expand Down
2 changes: 1 addition & 1 deletion src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageIconUrl>http://getakka.net/images/akkalogo.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/akkadotnet/Akka.Persistence.MongoDB</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/akkadotnet/Akka.Persistence.MongoDB/blob/master/LICENSE.md</PackageLicenseUrl>
<PackageReleaseNotes>Beta release of Akka.Persistence.MongoDB which implements the [new standardized Akka.Persistence serialization paradigm](https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/72) going forward. Has full backwards compatibility for reading events which were written in 1.3.[0-14] style serialization.</PackageReleaseNotes>
<PackageReleaseNotes>Fixed [an issue with Snapshot serialization in v1.4.0-beta1](https://github.com/akkadotnet/Akka.Persistence.MongoDB/pull/98)</PackageReleaseNotes>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>Akka Persistence journal and snapshot store backed by MongoDB database.</Description>
<NoWarn>$(NoWarn);CS1591</NoWarn>
Expand Down