Skip to content

Instantly share code, notes, and snippets.

@to11mtm
to11mtm / DData-DeDupe-wip.cs
Last active July 18, 2020 02:57
Distributed Data Dedupe alpha concept
using System;
using System.Linq;
using Akka.Actor;
using Akka.Cluster;
using Akka.DistributedData;
namespace Worker.Receiver.Deduplication.DData
{
public abstract class DeduplicatingReceiverBase : ActorBase
{
@to11mtm
to11mtm / ThreadAffinityDispatcher.cs
Created December 5, 2020 18:10
Thread Affinity Task Scheduler for Akka
// based heavily on https://github.com/noseratio/tpl/blob/master/ThreadAffinityTaskScheduler.cs
// //-----------------------------------------------------------------------
// // <copyright file="ThreadAffinityDispatcher.cs" company="Akka.NET Project">
// // Copyright (C) 2009-2020 Lightbend Inc. <http://www.lightbend.com>
// // Copyright (C) 2013-2020 .NET Foundation <https://github.com/akkadotnet/akka.net>
// // </copyright>
// //-----------------------------------------------------------------------
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System;
@to11mtm
to11mtm / BatchingStreamBuilder.CS
Last active June 25, 2021 02:32
A Helper to create a Batched stream based on a producer function
using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Pattern;
using Akka.Streams.Dsl;
using LanguageExt;
namespace Akka.Persistence.Sql.Linq2Db.Journal.DAO
{
public class BatchFlowControl
@to11mtm
to11mtm / AkkaStreamsAsyncEnumerable.cs
Created January 22, 2021 04:39
First take at a quick and dirty way to make an Akka stream into AsyncEnumerable.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Akka;
using Akka.Streams;
using Akka.Streams.Dsl;
namespace GlutenFree.Akka.Streams.AsyncEnumerable
{
@to11mtm
to11mtm / BigDecimal.cs
Created February 26, 2021 21:09 — forked from JcBernack/BigDecimal.cs
BigDecimal
using System;
using System.Numerics;
namespace Common
{
/// <summary>
/// Arbitrary precision decimal.
/// All operations are exact, except for division. Division never determines more digits than the given precision.
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d
/// Based on https://stackoverflow.com/a/4524254
@to11mtm
to11mtm / ThreadStatGatherer.cs
Last active November 17, 2021 02:04
Napkin-level measuring of thread stats over a period of time
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
public class ThreadStatGatherer : IDisposable
{
private List<int> ThreadStats = new List<int>();
private CancellationTokenSource runningCts = null;
@to11mtm
to11mtm / Linq2DbStreamSource
Created November 30, 2021 02:26
Akka Streams Linq2Db Streaming Reader source from IQueryable
using System;
using System.Collections.Generic;
using System.Linq;
using Akka.Streams.Dsl;
using LinqToDB;
using LinqToDB.Data;
namespace Akka.Persistence.Sql.Linq2Db.Streams
{
public class ReaderSource<T>
@to11mtm
to11mtm / AkkaStreamsGrpcHelpers.cs
Created December 26, 2021 04:11
NETCORE Grpc helpers for Akka.Streams
using System.Threading.Tasks;
using Akka;
using Akka.Streams;
using Akka.Streams.Dsl;
using Akka.Util;
using Google.Protobuf;
using Grpc.Core;
namespace GrpcAkkaStreamHelpers
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Reactive.Streams;
namespace Akka.Linq2Db.Sandbox
{
//THIS IS BACK OF NAPKIN CODE, COMPLETELY UNTESTED. USE AT OWN RISK
public class AsyncPublisherContextSubscription<T> : ISubscription
{
@to11mtm
to11mtm / EventLoopThreadScheduler.cs
Created February 1, 2022 22:50 — forked from noseratio/EventLoopThreadScheduler.cs
Single thread event loop scheduler, based on Rx EventLoopScheduler but with added SynchronizationContext and TPL TaskScheduler API
namespace Noseratio;
/// <summary>
/// Single thread event loop scheduler, based on Rx <seealso cref="EventLoopScheduler"/>
/// but with added SynchronizationContext and TPL TaskScheduler API
/// https://gist.github.com/noseratio/22a291e1d69f6d1cea547623ad9c9147
/// </summary>
public sealed partial class EventLoopThreadScheduler :
TaskScheduler,
IScheduler,