Skip to content

Instantly share code, notes, and snippets.

@Aaronontheweb
Created January 10, 2024 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aaronontheweb/f07eb00d21999b8dd9794af716b1c8a2 to your computer and use it in GitHub Desktop.
Save Aaronontheweb/f07eb00d21999b8dd9794af716b1c8a2 to your computer and use it in GitHub Desktop.
Akka.Analyzer demos
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);
});
}
}
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