Within
and ExpectNoMsg
in combination together right now
ExpectNoMsg
to pass
Within
block
ExpectNoMsg
waits until max
Within
assertion always fails
min < time actually ran < max
min < time actually ran < max + epsilon
Within
block's public-facing time parameter
RemainingOrDefault
fields
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);
}
Interceptor<T1, T2>
is alias for Func<T1, Delegation<T2>>
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
Then
method is also and interceptor, it can be again combined with the next interceptor in queue
_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
_increment.Then(_double).Then(i => Delegation.Inner(i.ToString()))
Then
method definition from the snippet above is an example
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)
}
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