Skip to content

Instantly share code, notes, and snippets.

View Danthar's full-sized avatar

Arjen Smits Danthar

  • The Netherlands
View GitHub Profile
[TestFixture()]
public class ChangeModeTests : RavenTestDriver
{
public ChangeModeTests()
{
ConfigureServer(new TestServerOptions()
{
});
}
@Danthar
Danthar / ParralelProcessingStream.cs
Last active July 21, 2021 13:18
Unlimited Parrallel processing flows example
/// a=>process1 =>ack
/// / \
/// / \
/// a=>(a)=>BROADCAST - a=>process2 =>ack ZIP=>transform(a, completionSignal)
/// \ /
/// \ /
/// a=>process3 => ack
public static Flow<I, O, NotUsed> ParralelProcessingStream<I, O>(params Flow<I, O, NotUsed>[] processingFlows)
{
return Flow.FromGraph(GraphDsl.Create(builder =>
@Danthar
Danthar / gist:94054550f42f287a3a0be78f142526bf
Last active July 20, 2021 14:02
c# PassThroughFlow example Akka.Streams
/// <summary>
/// As translated from: https://doc.akka.io/docs/alpakka/current/patterns.html#passthrough
/// </summary>
public class PassThroughFlow
{
public static IGraph<FlowShape<A, (T,A)>, NotUsed> create<A,T>(Flow<A, T, NotUsed> flow) {
return create(flow, Keep.Both);
}
[Test]
public void Can_Serialize_ICommandResult_With_Sql_Exception()
{
SqlException exception;
try
{
throw SqlExceptionCreator.NewSqlException(101);
} catch(SqlException ex)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackReferencedProjectOutputs</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
// we put this target in an props file and import it
<Target Name="PackReferencedProjectOutputs" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackReferencedProjectOutputs</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
// we put this target in an props file and import it
<Target Name="PackReferencedProjectOutputs" DependsOnTargets="BuildOnlySettings;ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
@Danthar
Danthar / gist:30ee6133294e3f1a85dcd5bc948fc625
Last active August 31, 2017 13:53
EventAdapters Persistence review based on changes
Premise:
We need an extra manifest column for EventAdapters. Because SerializerWithStringManifest type serializers are not compatible.
Findings:
EventAdapters are registered via an ActorSystem extension. And they are utilised based on an type -> adapter mapper. Which means if you want to utilise them you have to provide a mapping for the message type you want to use it on. Same concept as how serialization-bindings work.
EventAdapters are layered in the persistence system. Like a layer of a sandwich :P.
@Danthar
Danthar / cluster config TraderActor SM host
Created May 26, 2017 10:16
Akka.net cluster singleton example
cluster {
seed-nodes = ["akka.tcp://TradingRoomActors@localhost:8083"]
roles = ["traderworker"]
singleton {
singleton-name = "TraderActor"
role = "traderworker"
hand-over-retry-interval = 1s
}
singleton-proxy {
singleton-name = "TradesActor"
@Danthar
Danthar / gist:a41b42442d0d996e0903
Created November 7, 2014 13:15
Example of mapping action parameters in an actionattribute for MVC
public class LogAttribute : ActionFilterAttribute {
private IDictionary<string, object> parameters;
private string description;
public LogAttribute(string description) {
this.description = description;
}
public override void OnActionExecuting(ActionExecutingContext filterContext) {
parameters = filterContext.ActionParameters;
public abstract class BackoffProtocol
{
/// <summary>
/// I made the TrackedMsg generic so you wont have to do manual matching in your child actor.
/// Downside is, that it limits your communication options with the child actor.
/// </summary>
/// <typeparam name="T"></typeparam>
[Serializable]
public sealed class TrackedMsg<T>
{