Skip to content

Instantly share code, notes, and snippets.

Arjen Smits Danthar

  • The Netherlands
Block or report user

Report or block Danthar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Danthar
Danthar / gist:30ee6133294e3f1a85dcd5bc948fc625
Last active Aug 31, 2017
EventAdapters Persistence review based on changes
View gist:30ee6133294e3f1a85dcd5bc948fc625
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
Akka.net cluster singleton example
View cluster config TraderActor SM host
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"
View Akka serializer test helper
public static class SerializerTestHelpers
{
public static async Task<T> AkkaSerialized<T>(this T src)
{
var hocon = "akka.actor.provider = \"Akka.Remote.RemoteActorRefProvider, Akka.Remote\"" +
Environment.NewLine +
"akka.remote.helios.tcp.port = 0" + Environment.NewLine +
"akka.remote.helios.tcp.hostname = localhost";
var sys = ActorSystem.Create("src");//, ConfigurationFactory.ParseString(hokon));
await sys.Terminate();
View App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka"/>
</configSections>
<akka>
<hocon>
akka {
stdout-loglevel = DEBUG
View akka aggregator
class AskAggregator<TReq, TRep> : ReceiveActor
{
public AskAggregator(IActorRef askFor, IActorRef replyTo, IEnumerable<TReq> items)
{
var requestCount = items.Count();
var replies = new HashSet<TRep>();
foreach (var request in items)
askFor.Tell(request);
View Akka retrying backoffsupervisor
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>
{
View gist:3905f3fa89ecdf0023e5
2015-07-08 14:10:41.588 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b/processor to akka://Importer/user/stamdata/importRouter/$b/processor was not delivered. 1 dead letters encountered."
2015-07-08 14:10:41.589 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b to akka://Importer/user/stamdata/importRouter/$b was not delivered. 2 dead letters encountered."
2015-07-08 14:10:41.589 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b/processor/database to akka://Importer/user/stamdata/importRouter/$b/processor/database was not delivered. 3 dead letters encountered."
2015-07-08 14:10:41.590 +02:00 [Information] "Message DeathWatchNotification from akka://Importer/user/stamdata/importRouter/$b to akka://Importer/user/stamdata/importRouter/$b was not delivered. 4 dead letters encountered."
2015-07-08 14:10:41.591 +02:00 [Information] "Message DeathWatchNo
@Danthar
Danthar / gist:5e2812d3d6ca31129c01
Last active Aug 29, 2015
Router supervisionstrategies
View gist:5e2812d3d6ca31129c01
using System;
using Akka.Actor;
using Akka.Routing;
namespace Akka.RouterStrategies
{
class Program
{
static void Main(string[] args) {
var system = ActorSystem.Create("failboat");
@Danthar
Danthar / Throttler.cs
Created Jun 18, 2015
Basic throttler
View Throttler.cs
//Usefull for consumer/producer processing where you keep track of how many work you have served up in the producer
//and call Wait with that amount
//then consumer will call Hit to signal some work has been completed.
//producer will block on Wait until consumer has catched up
public class Throttler {
private AutoResetEvent resetEvent = new AutoResetEvent(false);
private int counter;
private int throttleAmount;
@Danthar
Danthar / gist:12f1b2dd229d4e58927a
Created Jun 8, 2015
Start werkzaamheden - command based - vanaf scratch poc
View gist:12f1b2dd229d4e58927a
public class WerkbonAggregate {
private WerkbonModel _state;
private List<object> _uncommittedEvents = new List<object>();
public WerkbonAggregate(WerkbonModel state) {
_state = state;
}
public void StartWerkzaamHeden(DateTime gestartOp){
You can’t perform that action at this time.