-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into #108_Azure_does_not_work_with_Akka.Cluster.Sh…
…arding # Conflicts: # src/Akka.Persistence.Azure.Tests/AzurePersistenceConfigSpec.cs # src/Akka.Persistence.Azure/Journal/AzureTableStorageJournalSettings.cs # src/Akka.Persistence.Azure/Snapshot/AzureBlobSnapshotStoreSettings.cs # src/Akka.Persistence.Azure/reference.conf
- Loading branch information
Showing
13 changed files
with
240 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#### 0.6.0-rc2 March 10 2020 #### | ||
**Beta Release of Akka.Persistence.Azure** | ||
#### 0.6.1 July 10 2020 #### | ||
**Release of Akka.Persistence.Azure** | ||
|
||
Upgraded Akka.Persistence.Azure v0.5.0 to target [the new Akka.NET v1.4 interfaces](https://getakka.net/community/whats-new/akkadotnet-v1.4.html). | ||
- Default configuration and documentation improvements | ||
- Fixed Akka.Cluster.Sharding support (see https://github.com/petabridge/Akka.Persistence.Azure/issues/98) | ||
|
||
---- | ||
#### 0.6.0 March 12 2020 #### | ||
**Release of Akka.Persistence.Azure** | ||
|
||
Akka.Persistence.Azure v0.5.0 is a major leap forward ahead of v0.1.0. It fully implements Akka.Persistence.Query and fully implements Akka.NET v1.4.0-compatible serialization techniques. | ||
|
||
There are still some issues with respect to ordering and result sets from Akka.Persistence.Query and those will be addressed in a future release of Akka.Persistence.Azure. | ||
Updates Akka version to 1.4.1 |
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
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
32 changes: 32 additions & 0 deletions
32
src/Akka.Persistence.Azure.Tests/AzureTableJournalEscapePersistentIdSpec.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,32 @@ | ||
using System; | ||
using System.Reflection; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Persistence.Azure.TestHelpers; | ||
using Akka.Persistence.TCK; | ||
using Akka.Persistence.TCK.Journal; | ||
using Akka.TestKit; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static Akka.Persistence.Azure.Tests.Helper.AzureStorageConfigHelper; | ||
|
||
namespace Akka.Persistence.Azure.Tests | ||
{ | ||
public class AzureTableJournalEscapePersistentIdSpec : AzureTableJournalSpec, IClassFixture<WindowsAzureStorageEmulatorFixture> | ||
{ | ||
public AzureTableJournalEscapePersistentIdSpec(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void PreparePersistenceId(string pid) | ||
{ | ||
base.PreparePersistenceId(pid); | ||
|
||
// Before storage is initialized, let's set Pid to the value that needs to be encoded | ||
var persistenceIdUsedForTests = typeof(PluginSpec).GetField($"<{nameof(Pid)}>k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); | ||
var currentValue = persistenceIdUsedForTests.GetValue(this).ToString(); | ||
persistenceIdUsedForTests.SetValue(this, $"some/path/to/encode/{currentValue}"); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Akka.Persistence.Azure.Tests/PartitionKeyEscapeHelperSpecs.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,24 @@ | ||
using Akka.Actor; | ||
using Akka.Persistence.Azure.Util; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Persistence.Azure.Tests | ||
{ | ||
public class PartitionKeyEscapeHelperSpecs | ||
{ | ||
[Theory] | ||
[InlineData("/system/sharding/areaCoordinator/singleton/coordinator")] | ||
[InlineData("/system/sha$rding/areaCoordinator/single$ton/coordinator$")] | ||
[InlineData("/system/sha$$$rding/areaCoord/inator$$/single$ton/coord$inator$")] | ||
public void Should_escape_correctly(string partitionKey) | ||
{ | ||
var escapedKey = PartitionKeyEscapeHelper.Escape(partitionKey); | ||
escapedKey.Should().NotContain("/"); | ||
var originalKey = PartitionKeyEscapeHelper.Unescape(escapedKey); | ||
originalKey.Should().Be(partitionKey); | ||
} | ||
} | ||
|
||
class A : ReceiveActor{ } | ||
} |
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
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
60 changes: 60 additions & 0 deletions
60
src/Akka.Persistence.Azure/Util/PartitionKeyEscapeHelper.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,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Akka.Persistence.Azure.Util | ||
{ | ||
/// <summary> | ||
/// PartitionKeyEscapeHelper | ||
/// </summary> | ||
public static class PartitionKeyEscapeHelper | ||
{ | ||
/// <summary> | ||
/// Sequence we need to escape | ||
/// </summary> | ||
private const string InvalidSequence = "/"; | ||
/// <summary> | ||
/// Sequence we use to escape invalid chars | ||
/// </summary> | ||
/// <remarks> | ||
/// Using $ here to resolve https://github.com/petabridge/Akka.Persistence.Azure/issues/98 | ||
/// Actor names never start with $ sign, which helps to decode encoded keys | ||
/// </remarks> | ||
private const string EscapeSequence = "$"; | ||
|
||
/// <summary> | ||
/// Escape special characters in partition key | ||
/// </summary> | ||
/// <returns>Escaped partition key</returns> | ||
public static string Escape(string partitionKey) | ||
{ | ||
var escapedKey = partitionKey; | ||
// First, replate escape sequence in case if it is used in original key | ||
escapedKey = escapedKey.Replace(EscapeSequence, EscapeSequence + EscapeSequence); | ||
|
||
// Now escape special chars | ||
escapedKey = escapedKey.Replace(InvalidSequence, EscapeSequence); | ||
|
||
return escapedKey; | ||
} | ||
|
||
/// <summary> | ||
/// Unescape previously escaped partition key | ||
/// </summary> | ||
/// <returns>Original, unescaped partition key</returns> | ||
public static string Unescape(string escapedKey) | ||
{ | ||
var originalKey = escapedKey; | ||
var uuid = Guid.NewGuid().ToString("N"); | ||
// Do not touch duplicated escape sequence - we will replace them later | ||
originalKey = originalKey.Replace(EscapeSequence + EscapeSequence, uuid); | ||
|
||
// Restore escaped characters | ||
originalKey = originalKey.Replace(EscapeSequence, InvalidSequence); | ||
|
||
// Now it is safe to decode duplicated sequences | ||
originalKey = originalKey.Replace(uuid, EscapeSequence); | ||
|
||
return originalKey; | ||
} | ||
} | ||
} |
Oops, something went wrong.