These are chat archives for akkadotnet/akka.net

28th
Jun 2016
Aaron Stannard
@Aaronontheweb
Jun 28 2016 00:08
@maxim-s got your other Akka.Remote MNTR spec to pass too
the remote re-deployment one
your code exposed a bug inside the Akka.Remote.TestKit which caused it not to work
I'll push a PR in a moment - but here's the good news: looks like we have the entire Akka.Remote MNTR test suite ported and passing now
so that's big news
Maxim Salamatko
@maxim-s
Jun 28 2016 00:10
@Aaronontheweb great!
Aaron Stannard
@Aaronontheweb
Jun 28 2016 00:11
it was a super subtle issue, but basically that spec was the first one to ever touch two entire code paths inside the test kit :p
which is why it had gone unnoticed lol
I also found a bug with the Akka.TestKit itself
but worked around that one
basically you can't use Within and ExpectNoMsg in combination together right now
because in order for the ExpectNoMsg to pass
it has to wait the full length of the Within block
and the within block defines it's time range as [min, max)
so if ExpectNoMsg waits until max
the Within assertion always fails
we should probably use some sort of epsilon value for the Within check
instead of having it check to see if min < time actually ran < max
we check min < time actually ran < max + epsilon
where epsilon is a trivially small value
I used 200ms
Aaron Stannard
@Aaronontheweb
Jun 28 2016 00:17
does that sound like a workable solution @maxim-s? It's not super high priority but it was the first bug I ran into while debugging the test
Maxim Salamatko
@maxim-s
Jun 28 2016 00:18
looks like yes
Aaron Stannard
@Aaronontheweb
Jun 28 2016 00:19
cool, I'll file a bug
that should be relatively straightforward to implement
the important part is just to make sure the epsilon doesn't get included as part of the Within block's public-facing time parameter
which gets used in the RemainingOrDefault fields
it should only be used during the assertion part
otherwise it won't fix the problem :p
btw, would you mind reviewing this? akkadotnet/akka.net#2103 - both @alexvaluyskiy and I worked on this although he did the vast majority of the work
all I did was fix the MNTR specs and put some backwards compatibility changes back in-place
but that PR fixes Clustered routers
and I need some of that code for implementing Akka.Cluster.Metrics
someone else, maybe @alexvaluyskiy or @Silv3rcircl3 will need to review akkadotnet/akka.net#2120 since both you and I worked on that one
Aaron Stannard
@Aaronontheweb
Jun 28 2016 00:38
this one is also ready for review: akkadotnet/akka.net#2113
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 10:18
Hello Akka.Net geeks. I have read about the actor model. I have some hands on Orleans, Akka.Net and the java Akka.io. However I have a project that I am about to embark on using the Akka.Net framework. It is a challenge thrown at me. I came up with an architectural design as follow:
  • The system will be modular. Each module will be an actor and it can be turned on or off via config(I have figured out how to do that)
  • The system will be have a message broadcaster that will be used to publish message.
  • When a message is published it has to go through some steps of handling(for instance authorization, validation, billing and co)
  • Each actor or module will act on the message published depending upon its position in the pipeline.
  • So at the end of the day the message will go through some tunnel till completion.
    I would like to know how best I can use Akka.Net to handle this and if it is possible I will need some coaching in term of design. Thank you.
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 10:52
@Tochemey this really depends on the details i.e.:
  • Modularity is build into akka itself - you can fairly easily create some config-driven functionality, and encapsulate it in form of an extension to akka. Many things work that way, including persistence or cluster support.
  • There are few different ways on how to broadcast messages:
    • when broadcasting in scope of particular node you can use EventBus or construct a broadcast router actor
    • when broadcasting in scope of the whole cluster you can extend routers to be cluster aware, or you can use distributed pub/sub
  • when it comes to pipelining, you could define a hierarchy of actors to handle it or use Akka.Streams, which give a lot of higher-level features, eg. they handle things like potential message overflows and can optimize some work defined within workflows.
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 10:58
I am reading something interesting from the Java version called Receive Pipeline. I would like to know whether Akka.Net have such feature. http://doc.akka.io/docs/akka/2.4.1/contrib/receive-pipeline.html
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 11:16
@Tochemey I belive this is an equivalent:
enum DelegationType { Handled, Inner }
struct Delegation<T> {
  public readonly DelegationType Type;
  public readonly T Value;
  public Delegation(DelegationType type, T value) {
    Type = type;
    Value = value;
  }
}
using Interceptor<T1, T2> = Func<T1, Delegation<T2>>;
static class Delegation {
  static Delegation<T> Inner<T>(T value) => new Delegation<T>(DelegationType.Inner, value);
  static Delegation<T> Handled<T>(T value) => new Delegation<T>(DelegationType.Handled, value);
  // extension methods
  static Interceptor<T1, T3> Then<T1, T2, T3>(this Interceptor<T1, T2> first, Interceptor<T2, T3> second) =>
    (input) => {
      var delegation = first(input);
      return delegation.Type == Handled ? delegation : second(delegation.Value);
    }    
}

// example 
class SomeActor : UntypedActor {
  Interceptor<int, int> _increment = i => Delegation.Inner(i + 1);
  Interceptor<int, int> _double = i => Delegation.Inner(i * 2);
  Interceptor<int, int> _pipeline = _increment.Then(_double);
  void OnReceive(object msg) => Console.WriteLine(_pipeline((int)msg).Value);
}
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 11:18
@Horusiath Thank you I will look into it.
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 12:10
@Horusiath Please I can not figure out the Interceptor part.
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 12:23
Also is it design extensible to any number of interceptors?
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 13:02
@Tochemey this is something, that in FP is called function pipelining. The crucial part is sending (conditionally) an output of one delegate as input to the next one, and wrapping that as a delegate with the same signature.
in this case Interceptor<T1, T2> is alias for Func<T1, Delegation<T2>>
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 13:04
Do we have function pipelining in c#?
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 13:04
and Then method is used to combine output of first interceptor delegate as an input to second delegate - but only if returned value is not of type Handled, because if it is, we're simply forwarding this result at the end of the pipeline
yes, any language with higher functions have it
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 13:06
I am using c# and I do not know whether it has it.
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 13:06
and since result of Then method is also and interceptor, it can be again combined with the next interceptor in queue
higher order function is when function (or method in case of C#) can take other function/method as an input parameter and return function/method as a result
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 13:12
in the example, I've show you have two interceptors inside of an actor: _increment and _double, which are combined using _increment.Then(_decrement) - this will return another interceptor (see _pipeline), which will act as combination for those two. And since _pipeline is also an interceptor, so you can combine it with any other interceptor you wish using Then
i.e. _increment.Then(_double).Then(i => Delegation.Inner(i.ToString()))
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 13:31
@Horusiath how can I implement function pipeline in c#
Bartosz Sypytkowski
@Horusiath
Jun 28 2016 13:32
@Tochemey Then method definition from the snippet above is an example
Arsene Tochemey GANDOTE
@Tochemey
Jun 28 2016 13:55
B
I got it. Thank you
Alex Valuyskiy
@alexvaluyskiy
Jun 28 2016 15:18
I need help with translation this code to C#
    implicit val ringOrdering: Ordering[UniqueAddress] = Ordering.fromLessThan[UniqueAddress] { (a, b) ⇒
      val ha = a.##
      val hb = b.##
      ha < hb || (ha == hb && Member.addressOrdering.compare(a.address, b.address) < 0)
    }
Aaron Stannard
@Aaronontheweb
Jun 28 2016 15:19
a.## == get hashcode for a
Alex Valuyskiy
@alexvaluyskiy
Jun 28 2016 15:19
Good. I think I found something in cluster. Trying to fix
Aaron Stannard
@Aaronontheweb
Jun 28 2016 15:20
so the unique address must have some overridden property that uses a piece of real data to represent the hash code
I don't know why they would make that sortable though if it's using something like the UID, which is random
well actually nevermind
I guess determining the "oldest" UID isn't the point
it's guaranteeing that all of the nodes are always sorted in the same order everywhere in the cluster
ok, that makes more sense then
Alex Valuyskiy
@alexvaluyskiy
Jun 28 2016 15:23

Is this code mean https://github.com/akka/akka/blob/master/akka-cluster/src/main/scala/akka/cluster/ClusterHeartbeat.scala#L27

            Receive<ClusterHeartbeatSender.Heartbeat>(heartbeat =>
            {
                if (heartbeat.From != null)
                {
                    Sender.Tell(_selfHeartbeatRsp);
                }
            });

Our current implementation doesn't have IF

Aaron Stannard
@Aaronontheweb
Jun 28 2016 15:24
oh ouch
is it ever possible for that field to be null?
technically shouldn't be
keep up the good work - I'm off doing some customer-facing work today so I'll be offline until later tonight PST. I'll update my dispatchers PR when I get back
Damian Reeves
@DamianReeves
Jun 28 2016 16:32
So when is the next Akka release scheduled?
Marc Piechura
@marcpiechura
Jun 28 2016 16:34
@DamianReeves scheduled for the 30th but maybe take a few days longer
Damian Reeves
@DamianReeves
Jun 28 2016 16:34
thanks
Maciek Misztal
@mmisztal1980
Jun 28 2016 23:43
fingers crossed
Chris Ochs
@gamemachine
Jun 28 2016 23:56
Is there a way to make akka testkit not swallow all exceptions?