/// <summary> /// Initializes a new instance of the <see cref="ClusterClient" /> class. /// </summary> /// <param name="settings">The settings used to configure the client.</param> /// <exception cref="ArgumentException"> /// This exception is thrown when the settings contains no initial contacts. /// </exception> public ClusterClient(ClusterClientSettings settings) { if (settings.InitialContacts.Count == 0) { throw new ArgumentException("Initial contacts for cluster client cannot be empty"); } _settings = settings; _failureDetector = new DeadlineFailureDetector(_settings.AcceptableHeartbeatPause, _settings.HeartbeatInterval); _contactPaths = settings.InitialContacts.ToImmutableHashSet(); _initialContactsSelections = _contactPaths.Select(Context.ActorSelection).ToArray(); _contacts = _initialContactsSelections; SendGetContacts(); _contactPathsPublished = ImmutableHashSet <ActorPath> .Empty; _subscribers = ImmutableList <IActorRef> .Empty; _heartbeatTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( settings.HeartbeatInterval, settings.HeartbeatInterval, Self, HeartbeatTick.Instance, Self); _refreshContactsCancelable = null; ScheduleRefreshContactsTick(settings.EstablishingGetContactsInterval); Self.Tell(RefreshContactsTick.Instance); _buffer = new Queue <Tuple <object, IActorRef> >(); }
/// <summary> /// Factory method for <see cref="ClusterClient"/> <see cref="Actor.Props"/>. /// </summary> /// <param name="settings">TBD</param> /// <exception cref="ArgumentNullException"> /// This exception is thrown when the specified <paramref name="settings"/> is undefined. /// </exception> /// <returns>TBD</returns> public static Props Props(ClusterClientSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } return(Actor.Props.Create(() => new ClusterClient(settings)).WithDeploy(Deploy.Local)); }
public ClusterClient(ClusterClientSettings settings) { if (!settings.InitialContacts.Any()) { throw new ArgumentException("Initial contacts for cluster client cannot be empty"); } Settings = settings; _failureDetector = new DeadlineFailureDetector(Settings.AcceptableHeartbeatPause, () => Settings.HeartbeatInterval.Ticks); _initialContactsSelections = settings.InitialContacts.Select(Context.ActorSelection).ToArray(); _contacts = _initialContactsSelections; _buffer = new Queue <Tuple <object, IActorRef> >(); SendGetContacts(); _heartbeatCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( settings.HeartbeatInterval, settings.HeartbeatInterval, Self, InternalMessage.HeartbeatTick, Self); ScheduleRefreshContactsTick(settings.EstablishingGetContactsInterval); Self.Tell(InternalMessage.RefreshContactsTick); }
public ClusterClient(ClusterClientSettings settings) { if (settings.InitialContacts.Count == 0) { throw new ArgumentException("Initial contacts for cluster client cannot be empty"); } _settings = settings; _failureDetector = new DeadlineFailureDetector(_settings.AcceptableHeartbeatPause, _settings.HeartbeatInterval); _contactPaths = settings.InitialContacts.ToImmutableHashSet(); _initialContactsSelections = _contactPaths.Select(Context.ActorSelection).ToArray(); _contacts = _initialContactsSelections; SendGetContacts(); _contactPathsPublished = ImmutableHashSet<ActorPath>.Empty; _subscribers = ImmutableList<IActorRef>.Empty; _heartbeatTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( settings.HeartbeatInterval, settings.HeartbeatInterval, Self, HeartbeatTick.Instance, Self); _refreshContactsCancelable = null; ScheduleRefreshContactsTick(settings.EstablishingGetContactsInterval); Self.Tell(RefreshContactsTick.Instance); _buffer = new Queue<Tuple<object, IActorRef>>(); }
/// <summary> /// Factory method for <see cref="ClusterClient"/> <see cref="Actor.Props"/>. /// </summary> public static Props Props(ClusterClientSettings settings) { if (settings == null) throw new ArgumentNullException(nameof(settings)); return Actor.Props.Create(() => new ClusterClient(settings)).WithDeploy(Deploy.Local); }
public ClusterClient(ClusterClientSettings settings) { if (!settings.InitialContacts.Any()) throw new ArgumentException("Initial contacts for cluster client cannot be empty"); Settings = settings; _failureDetector = new DeadlineFailureDetector(Settings.AcceptableHeartbeatPause, () => Settings.HeartbeatInterval.Ticks); _initialContactsSelections = settings.InitialContacts.Select(Context.ActorSelection).ToArray(); _contacts = _initialContactsSelections; _buffer = new Queue<Tuple<object, IActorRef>>(); SendGetContacts(); _heartbeatCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( settings.HeartbeatInterval, settings.HeartbeatInterval, Self, InternalMessage.HeartbeatTick, Self); ScheduleRefreshContactsTick(settings.EstablishingGetContactsInterval); Self.Tell(InternalMessage.RefreshContactsTick); }