Skip to content

Commit cd077a1

Browse files
AarononthewebmhbuckArkatufus
authored
[V3] ReceiveActor - Removing MatchBuilder and making use of handlers. Deleted all MatchHandler code (#7557)
* Initial working approach but very rough. * Consolidate * Potentially cleaner approach * Some clean up and comments. * Remove using * Added test and logic to prevent Any handler from being added twice * Wanting to confirm these tests are also passing on build This is probably not the most ideal code. I want to make sure the tests are passing better before getting to cleaning it up * TryHandle looks much neater * Closer to what I think the final layout will be * Moved classes out and starting on tests Still quite a bit of understanding of how the MatchBuilder was working * Test update. * More refinement * Getting more tests * Covering a bunch of the test cases * Minor Tweak * v1.6 - adjust `ReceiveActorHandlers` to ensure preservation of declared `Receive<T>` ordering a continuation of #7498 * removed comment * removed all `MatchHandler` garbage * made `ReceiveActor` nullable * convert `ReceiveActor.cs` back to UTF-8 * removed all `MatchHandler` references from `ReceivePersistentActor` * added API approvals * Fix failing unit test --------- Co-authored-by: Michael Buck <[email protected]> Co-authored-by: Gregorius Soedharmo <[email protected]>
1 parent 447b550 commit cd077a1

35 files changed

+703
-4303
lines changed

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.DotNet.verified.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,22 +1540,27 @@ namespace Akka.Actor
15401540
}
15411541
}
15421542
public delegate bool Receive(object message);
1543+
[System.Runtime.CompilerServices.NullableAttribute(0)]
15431544
public abstract class ReceiveActor : Akka.Actor.UntypedActor, Akka.Actor.Internal.IInitializableActor
15441545
{
15451546
protected ReceiveActor() { }
15461547
protected void Become(System.Action configure) { }
15471548
protected void BecomeStacked(System.Action configure) { }
15481549
protected virtual void OnReceive(object message) { }
1549-
protected void Receive<T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
1550-
protected void Receive<T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
1551-
protected void Receive(System.Type messageType, System.Action<object> handler, System.Predicate<object> shouldHandle = null) { }
1550+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
1551+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
1552+
protected void Receive(System.Type messageType, System.Action<object> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
1553+
2,
1554+
1})] System.Predicate<object> shouldHandle = null) { }
15521555
protected void Receive(System.Type messageType, System.Predicate<object> shouldHandle, System.Action<object> handler) { }
1553-
protected void Receive<T>(System.Func<T, bool> handler) { }
1556+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, bool> handler) { }
15541557
protected void Receive(System.Type messageType, System.Func<object, bool> handler) { }
15551558
protected void ReceiveAny(System.Action<object> handler) { }
15561559
protected void ReceiveAnyAsync(System.Func<object, System.Threading.Tasks.Task> handler) { }
1557-
protected void ReceiveAsync<T>(System.Func<T, System.Threading.Tasks.Task> handler, System.Predicate<T> shouldHandle = null) { }
1558-
protected void ReceiveAsync<T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
1560+
protected void ReceiveAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, System.Threading.Tasks.Task> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
1561+
2,
1562+
1})] System.Predicate<T> shouldHandle = null) { }
1563+
protected void ReceiveAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
15591564
protected void ReceiveAsync(System.Type messageType, System.Func<object, System.Threading.Tasks.Task> handler, System.Predicate<object> shouldHandle = null) { }
15601565
protected void ReceiveAsync(System.Type messageType, System.Predicate<object> shouldHandle, System.Func<object, System.Threading.Tasks.Task> handler) { }
15611566
}

src/core/Akka.API.Tests/verify/CoreAPISpec.ApproveCore.Net.verified.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,22 +1538,27 @@ namespace Akka.Actor
15381538
}
15391539
}
15401540
public delegate bool Receive(object message);
1541+
[System.Runtime.CompilerServices.NullableAttribute(0)]
15411542
public abstract class ReceiveActor : Akka.Actor.UntypedActor, Akka.Actor.Internal.IInitializableActor
15421543
{
15431544
protected ReceiveActor() { }
15441545
protected void Become(System.Action configure) { }
15451546
protected void BecomeStacked(System.Action configure) { }
15461547
protected virtual void OnReceive(object message) { }
1547-
protected void Receive<T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
1548-
protected void Receive<T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
1549-
protected void Receive(System.Type messageType, System.Action<object> handler, System.Predicate<object> shouldHandle = null) { }
1548+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
1549+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
1550+
protected void Receive(System.Type messageType, System.Action<object> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
1551+
2,
1552+
1})] System.Predicate<object> shouldHandle = null) { }
15501553
protected void Receive(System.Type messageType, System.Predicate<object> shouldHandle, System.Action<object> handler) { }
1551-
protected void Receive<T>(System.Func<T, bool> handler) { }
1554+
protected void Receive<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, bool> handler) { }
15521555
protected void Receive(System.Type messageType, System.Func<object, bool> handler) { }
15531556
protected void ReceiveAny(System.Action<object> handler) { }
15541557
protected void ReceiveAnyAsync(System.Func<object, System.Threading.Tasks.Task> handler) { }
1555-
protected void ReceiveAsync<T>(System.Func<T, System.Threading.Tasks.Task> handler, System.Predicate<T> shouldHandle = null) { }
1556-
protected void ReceiveAsync<T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
1558+
protected void ReceiveAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, System.Threading.Tasks.Task> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
1559+
2,
1560+
1})] System.Predicate<T> shouldHandle = null) { }
1561+
protected void ReceiveAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
15571562
protected void ReceiveAsync(System.Type messageType, System.Func<object, System.Threading.Tasks.Task> handler, System.Predicate<object> shouldHandle = null) { }
15581563
protected void ReceiveAsync(System.Type messageType, System.Predicate<object> shouldHandle, System.Func<object, System.Threading.Tasks.Task> handler) { }
15591564
}

src/core/Akka.API.Tests/verify/CoreAPISpec.ApprovePersistence.DotNet.verified.txt

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ namespace Akka.Persistence
205205
public DiscardConfigurator() { }
206206
public Akka.Persistence.IStashOverflowStrategy Create(Akka.Configuration.Config config) { }
207207
}
208+
[System.Runtime.CompilerServices.NullableAttribute(0)]
208209
public class DiscardToDeadLetterStrategy : Akka.Persistence.IStashOverflowStrategy
209210
{
210211
public static Akka.Persistence.DiscardToDeadLetterStrategy Instance { get; }
@@ -444,34 +445,44 @@ namespace Akka.Persistence
444445
protected PersistentActor() { }
445446
protected override bool Receive(object message) { }
446447
}
448+
[System.Runtime.CompilerServices.NullableAttribute(0)]
447449
public abstract class ReceivePersistentActor : Akka.Persistence.UntypedPersistentActor, Akka.Actor.Internal.IInitializableActor
448450
{
449451
protected ReceivePersistentActor() { }
450452
protected void Become(System.Action configure) { }
451453
protected void BecomeStacked(System.Action configure) { }
452-
protected void Command<T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
453-
protected void Command<T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
454-
protected void Command(System.Type messageType, System.Action<object> handler, System.Predicate<object> shouldHandle = null) { }
454+
protected void Command<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Action<T> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
455+
2,
456+
1})] System.Predicate<T> shouldHandle = null) { }
457+
protected void Command<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
458+
protected void Command(System.Type messageType, System.Action<object> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
459+
2,
460+
1})] System.Predicate<object> shouldHandle = null) { }
455461
protected void Command(System.Type messageType, System.Predicate<object> shouldHandle, System.Action<object> handler) { }
456-
protected void Command<T>(System.Func<T, bool> handler) { }
462+
protected void Command<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, bool> handler) { }
457463
protected void Command(System.Type messageType, System.Func<object, bool> handler) { }
458464
protected void Command(System.Action<object> handler) { }
459465
protected void CommandAny(System.Action<object> handler) { }
460466
protected void CommandAnyAsync(System.Func<object, System.Threading.Tasks.Task> handler) { }
461-
protected void CommandAsync<T>(System.Func<T, System.Threading.Tasks.Task> handler, System.Predicate<T> shouldHandle = null) { }
462-
protected void CommandAsync<T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
467+
protected void CommandAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, System.Threading.Tasks.Task> handler, System.Predicate<T> shouldHandle = null) { }
468+
protected void CommandAsync<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Func<T, System.Threading.Tasks.Task> handler) { }
463469
protected void CommandAsync(System.Type messageType, System.Func<object, System.Threading.Tasks.Task> handler, System.Predicate<object> shouldHandle = null) { }
464470
protected void CommandAsync(System.Type messageType, System.Predicate<object> shouldHandle, System.Func<object, System.Threading.Tasks.Task> handler) { }
465471
protected virtual void OnCommand(object message) { }
466472
protected virtual void OnRecover(object message) { }
467-
protected void Recover<T>(System.Action<T> handler, System.Predicate<T> shouldHandle = null) { }
468-
protected void Recover<T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
469-
protected void Recover(System.Type messageType, System.Action<object> handler, System.Predicate<object> shouldHandle = null) { }
473+
protected void Recover<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Action<T> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
474+
2,
475+
1})] System.Predicate<T> shouldHandle = null) { }
476+
protected void Recover<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Predicate<T> shouldHandle, System.Action<T> handler) { }
477+
protected void Recover(System.Type messageType, System.Action<object> handler, [System.Runtime.CompilerServices.NullableAttribute(new byte[] {
478+
2,
479+
1})] System.Predicate<object> shouldHandle = null) { }
470480
protected void Recover(System.Type messageType, System.Predicate<object> shouldHandle, System.Action<object> handler) { }
471-
protected void Recover<T>(System.Func<T, bool> handler) { }
481+
protected void Recover<[System.Runtime.CompilerServices.NullableAttribute(2)] T>(System.Func<T, bool> handler) { }
472482
protected void Recover(System.Type messageType, System.Func<object, bool> handler) { }
473483
protected void RecoverAny(System.Action<object> handler) { }
474484
}
485+
[System.Runtime.CompilerServices.NullableAttribute(0)]
475486
public sealed class Recovery
476487
{
477488
public Recovery() { }
@@ -484,6 +495,7 @@ namespace Akka.Persistence
484495
public long ReplayMax { get; }
485496
public long ToSequenceNr { get; }
486497
}
498+
[System.Runtime.CompilerServices.NullableAttribute(0)]
487499
public sealed class RecoveryCompleted
488500
{
489501
public static readonly Akka.Persistence.RecoveryCompleted Instance;
@@ -504,10 +516,11 @@ namespace Akka.Persistence
504516
public RecoveryTick(bool snapshot) { }
505517
public bool Snapshot { get; }
506518
}
519+
[System.Runtime.CompilerServices.NullableAttribute(0)]
507520
public sealed class RecoveryTimedOutException : Akka.Actor.AkkaException
508521
{
509522
public RecoveryTimedOutException() { }
510-
public RecoveryTimedOutException(string message, System.Exception cause = null) { }
523+
public RecoveryTimedOutException(string message, [System.Runtime.CompilerServices.NullableAttribute(2)] System.Exception cause = null) { }
511524
public RecoveryTimedOutException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
512525
}
513526
public sealed class ReplayMessages : Akka.Actor.INoSerializationVerificationNeeded, Akka.Persistence.IJournalMessage, Akka.Persistence.IJournalRequest, Akka.Persistence.IPersistenceMessage, System.IEquatable<Akka.Persistence.ReplayMessages>
@@ -541,6 +554,7 @@ namespace Akka.Persistence
541554
public override int GetHashCode() { }
542555
public override string ToString() { }
543556
}
557+
[System.Runtime.CompilerServices.NullableAttribute(0)]
544558
public sealed class ReplyToStrategy : Akka.Persistence.IStashOverflowStrategy
545559
{
546560
public ReplyToStrategy(object response) { }
@@ -638,6 +652,7 @@ namespace Akka.Persistence
638652
public ThrowExceptionConfigurator() { }
639653
public Akka.Persistence.IStashOverflowStrategy Create(Akka.Configuration.Config config) { }
640654
}
655+
[System.Runtime.CompilerServices.NullableAttribute(0)]
641656
public class ThrowOverflowExceptionStrategy : Akka.Persistence.IStashOverflowStrategy
642657
{
643658
public static Akka.Persistence.ThrowOverflowExceptionStrategy Instance { get; }
@@ -662,6 +677,7 @@ namespace Akka.Persistence
662677
public override int GetHashCode() { }
663678
public override string ToString() { }
664679
}
680+
[System.Runtime.CompilerServices.NullableAttribute(0)]
665681
public abstract class UntypedPersistentActor : Akka.Persistence.Eventsourced
666682
{
667683
protected UntypedPersistentActor() { }

0 commit comments

Comments
 (0)