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>>(); }
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); }