Skip to content

Instantly share code, notes, and snippets.

View Aaronontheweb's full-sized avatar
🚀
Shipping!

Aaron Stannard Aaronontheweb

🚀
Shipping!
View GitHub Profile
@Aaronontheweb
Aaronontheweb / Program.cs
Created April 12, 2024 13:23
Akka.NET - Deleting Older Snapshots in Akka.Persistence actors that ONLY use the SnapshotStore
async Task Main()
{
var actorSystem = ActorSystem.Create("Sys");
var persistentActor = actorSystem.ActorOf<ExamplePersistentActor>("exampleActor");
var watch = persistentActor.WatchAsync();
// Sending multiple "save" commands to create snapshots
persistentActor.Tell("save-1");
await Task.Delay(TimeSpan.FromSeconds(1)); // spacing out snapshots, time-wise
@Aaronontheweb
Aaronontheweb / docker-compose.yml
Created March 8, 2024 19:21
Jaeger docker compose
version: '3.7'
services:
jaeger:
image: jaegertracing/all-in-one:1.55
hostname: jaeger
restart: always
ports:
- '16686:16686'
- '5775:5775/udp'
@Aaronontheweb
Aaronontheweb / projections.cs
Last active March 5, 2024 16:08
Read Journal Provider
Command<ProjectionStarting>(_ =>
{
// TODO: seeing multiple of these being logged, which makes me think there's a problem with our Akka.Streams graph
_log.Info("Projection for Tag [{0}] is starting from Offset [{1}] - instance [{2}] rand [{3}]", NuGetPersistenceTags.NuGetProductTag,
CurrentState.LastOffset.AsLong(), Self.Path.Uid, Random.Shared.Next());
Sender.Tell(ProjectionAck.Instance);
});
Command<ProjectionCompleted>(_ =>
{
@Aaronontheweb
Aaronontheweb / genericparent.cs
Last active March 4, 2024 16:52
GenericChildPerEntityParent Actor
// -----------------------------------------------------------------------
// <copyright file="GenericChildPerEntityParent.cs" company="Akka.NET Project">
// Copyright (C) 2015-2023 .NET Petabridge, LLC
// </copyright>
// -----------------------------------------------------------------------
using Akka.Actor;
using Akka.Cluster.Sharding;
namespace Sdkbin.NuGet.Actors.Utility;
@Aaronontheweb
Aaronontheweb / delivery.linq
Last active February 15, 2024 18:05
Akka.Delivery stream
async Task Main()
{
var actorSystem = ActorSystem.Create("Sys");
var producerSettings = ProducerController.Settings.Create(actorSystem);
using var cts = new CancellationTokenSource();
var (queue, producerController) = StreamConstruction.CreateProducerStream<IMessageProtocol>(actorSystem, producerSettings, "myproducer", cts.Token);
var myConsumer = actorSystem.ActorOf(Props.Create(() => new ConsumerActor(producerController)), "consumer");
@Aaronontheweb
Aaronontheweb / killFunc.ps1
Created February 1, 2024 15:28
Cleanup Script for Azure Functions Local Debugging
$processNameContains = "func"
try {
# Get all processes where the name contains 'func'
$processesToKill = Get-Process | Where-Object { $_.ProcessName -like "*$processNameContains*" }
# Check if there are any processes to kill
if ($processesToKill) {
# Kill each process
foreach ($process in $processesToKill) {
@Aaronontheweb
Aaronontheweb / badpipeto.cs
Created January 10, 2024 17:26
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;
@Aaronontheweb
Aaronontheweb / perf.md
Created December 12, 2023 17:14
Akka.NET Historical performance numbers

Akka.NET v1.3.0, .NET 8

ProcessorCount: 16
ClockSpeed: 0 MHZ
Actor Count: 32
Messages sent/received per client: 20000 (2e4) Is Server GC: True

Num clients, Total [msg], Msgs/sec, Total [ms] 1, 20000, 45147, 443.66

@Aaronontheweb
Aaronontheweb / channeldispatcher.conf
Last active December 6, 2023 20:26
ChannelDispatcherHocon
akka.channel-scheduler {
parallelism-min = 4 #same as for ForkJoinDispatcher
parallelism-factor = 1 #same as for ForkJoinDispatcher
parallelism-max = 64 #same as for ForkJoinDispatcher
work-max = 10 #max executed work items in sequence until priority loop
work-interval = 500 #time target of executed work items in ms
work-step = 2 #target work item count in interval / burst
}
akka.actor.default-dispatcher = {
@Aaronontheweb
Aaronontheweb / packAll.ps1
Created September 25, 2023 21:50
Pack all nuget packages in directory
# Get the current directory
$currentDirectory = Get-Location
# Define a common output directory for the packed projects
$outputDirectory = Join-Path -Path $currentDirectory -ChildPath 'packed'
# Create the output directory if it doesn't exist
if (-not (Test-Path $outputDirectory)) {
New-Item -Path $outputDirectory -ItemType Directory
}