Created
January 10, 2024 17:26
-
-
Save Aaronontheweb/f07eb00d21999b8dd9794af716b1c8a2 to your computer and use it in GitHub Desktop.
Akka.Analyzer demos
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
using Akka.Actor; | |
using System.Threading.Tasks; | |
public sealed class MyActor : ReceiveActor{ | |
public MyActor(){ | |
Receive<string>(str => { | |
async Task<int> LocalFunction(){ | |
await Task.Delay(10); | |
return str.Length; | |
} | |
// incorrect use of closure | |
LocalFunction().PipeTo(Sender); | |
}); | |
} | |
} |
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
using Akka.Cluster.Sharding; | |
public class MsgExtractorCreator{ | |
IMessageExtractor Create(){ | |
IMessageExtractor messageExtractor = HashCodeMessageExtractor.Create(100, msg => | |
{ | |
if (msg is ShardingEnvelope shard) { | |
return shard.EntityId; | |
} | |
else if (msg is string s) { | |
return s; | |
} | |
else{ | |
return null; | |
} | |
}); | |
return messageExtractor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment