private MetricsSelector MetricsSelectorToProto(IMetricsSelector selector) { var serializer = _serialization.Value.FindSerializerFor(selector); return(new MetricsSelector() { Data = ByteString.CopyFrom(serializer.ToBinary(selector)), SerializerId = (uint)serializer.Identifier, Manifest = selector.GetType().TypeQualifiedName() }); }
/// <summary> /// Creates instance if <see cref="AdaptiveLoadBalancingRoutingLogic"/> /// </summary> /// <param name="system">The actor system hosting this router</param> /// <param name="metricsSelector"> /// Decides what probability to use for selecting a routee, based on remaining capacity as indicated by the node metrics /// </param> public AdaptiveLoadBalancingRoutingLogic(ActorSystem system, IMetricsSelector metricsSelector = null) { _system = system; _metricsSelector = metricsSelector ?? MixMetricsSelector.Instance; _cluster = Cluster.Get(system); // The current weighted routees, if any. Weights are produced by the metricsSelector // via the metricsListener Actor. It's only updated by the actor, but accessed from // the threads of the sender()s. _weightedRouteesRef = new AtomicReference <Tuple <ImmutableArray <Routee>, IImmutableSet <NodeMetrics>, Option <WeightedRoutees> > >( Tuple.Create <ImmutableArray <Routee>, IImmutableSet <NodeMetrics>, Option <WeightedRoutees> >( ImmutableArray <Routee> .Empty, ImmutableHashSet <NodeMetrics> .Empty, Option <WeightedRoutees> .None ) ); }
/// <summary> /// Creates new instance of <see cref="AdaptiveLoadBalancingGroup"/> from provided configuration /// </summary> /// <param name="metricsSelector"> /// Decides what probability to use for selecting a routee, /// based on remaining capacity as indicated by the node metrics /// </param> /// <param name="paths"> /// String representation of the actor paths of the routees, /// messages are sent with <see cref="ActorSelection"/> to these paths /// </param> /// <param name="routerDispatcher"> /// Dispatcher to use for the router head actor, which handles router management messages /// </param> public AdaptiveLoadBalancingGroup(IMetricsSelector metricsSelector = null, IEnumerable <string> paths = null, string routerDispatcher = null) : base(paths, routerDispatcher ?? Dispatchers.DefaultDispatcherId) { _metricsSelector = metricsSelector ?? MixMetricsSelector.Instance; }
/// <summary> /// Creates instance of <see cref="AdaptiveLoadBalancingPool"/> /// </summary> /// <param name="metricsSelector"> /// Decides what probability to use for selecting a routee, based on remaining capacity as indicated by the node metrics /// </param> /// <param name="nrOfInstances">Initial number of routees in the pool</param> /// <param name="supervisorStrategy">strategy for supervising the routees, see 'Supervision Setup' in class summary</param> /// <param name="routerDispatcher">Dispatcher to use for the router head actor, which handles supervision, death watch and router management messages</param> /// <param name="usePoolDispatcher"></param> public AdaptiveLoadBalancingPool(IMetricsSelector metricsSelector = null, int nrOfInstances = 0, SupervisorStrategy supervisorStrategy = null, string routerDispatcher = null, bool usePoolDispatcher = false) : base(nrOfInstances, null, supervisorStrategy ?? DefaultSupervisorStrategy, routerDispatcher ?? Dispatchers.DefaultDispatcherId, usePoolDispatcher) { MetricsSelector = metricsSelector ?? MixMetricsSelector.Instance; }