private void OnSubscribed(NatsSubscription subscription) { Logger.Info($"{nameof(OnSubscribed)}"); Script.Statements.Add(new ScriptStatement { Name = nameof(SubscribeCommand), Param1 = subscription.Subject, Param2 = "" }); }
private void OnItemDoubleClicked(string colName, NatsSubscription subscription) { if (subscription.Subscribed) { Unsubscribe(subscription); } else { Subscribe(subscription); } }
public void Unsubscribe(NatsSubscription natsSubscription) { if (Subscriptions.TryGetValue(natsSubscription, out var subs)) { foreach (var subscription in subs) { subscription.Unsubscribe(); } Subscriptions.Remove(natsSubscription); natsSubscription.Subscribed = false; Unsubscribed?.Invoke(natsSubscription); } }
public void Start() { if (natsClient.Start()) { discoverMessage = new VcapComponentDiscover( type: Resources.Agent_DEAComponentType, uuid: natsClient.UniqueIdentifier, host: config.MonitoringServiceHostStr, credentials: config.MonitoringCredentials); varzProvider.Discover = discoverMessage; natsClient.Subscribe(NatsSubscription.VcapComponentDiscover, (msg, reply) => { discoverMessage.UpdateUptime(); natsClient.Publish(reply, discoverMessage); }); natsClient.Publish(new VcapComponentAnnounce(discoverMessage)); natsClient.Subscribe(NatsSubscription.DeaStatus, ProcessDeaStatus); natsClient.Subscribe(NatsSubscription.DropletStatus, ProcessDropletStatus); natsClient.Subscribe(NatsSubscription.DeaDiscover, ProcessDeaDiscover); natsClient.Subscribe(NatsSubscription.DeaFindDroplet, ProcessDeaFindDroplet); natsClient.Subscribe(NatsSubscription.DeaUpdate, ProcessDeaUpdate); natsClient.Subscribe(NatsSubscription.DeaStop, ProcessDeaStop); natsClient.Subscribe(NatsSubscription.GetDeaInstanceStartFor(natsClient.UniqueIdentifier), ProcessDeaStart); natsClient.Subscribe(NatsSubscription.RouterStart, ProcessRouterStart); natsClient.Subscribe(NatsSubscription.HealthManagerStart, ProcessHealthManagerStart); natsClient.Subscribe(NatsSubscription.DeaLocate, ProcessDeaLocate); natsClient.Publish(helloMessage); SendAdvertise(); RecoverExistingDroplets(); processTask.Start(); heartbeatTask.Start(); advertiseTask.Start(); varzTask.Start(); monitorAppsTask.Start(); } else { log.Error(Resources.Agent_ErrorDetectedInNats_Message); Error = true; } }
public bool Create(NatsSubscription natsSubscription, out string msg) { Logger.Info($"Create NatsSubject: {natsSubscription.Subject}"); if (Configuration.GetSubject(natsSubscription.Subject) != null) { msg = $"A subject already exists with subject: {natsSubscription.Subject}"; Logger.Warn(msg); return(false); } Configuration.Add(natsSubscription); Configuration.Save(NatsXml); msg = $"NatsSubject created: {natsSubscription}"; return(true); }
protected void CreateSubscription() { Logger.Info($"{nameof(CreateSubscription)}: {Model}"); var natsSubscription = new NatsSubscription(Model.Subject) { Checked = false, Subscribed = false }; if (NatsService.Create(natsSubscription, out _)) { Subscriptions.Insert(0, natsSubscription); } Subscribe(natsSubscription); }
private void OnItemClicked(string colName, NatsSubscription subscription) { switch (colName) { case nameof(NatsSubscription.Unsubscribe): Unsubscribe(subscription); break; case nameof(NatsSubscription.Subscribe): Subscribe(subscription); break; case nameof(NatsSubscription.Trash): Logger.Info($"{nameof(NatsSubscription.Trash)}: {subscription}"); NatsService.Remove(subscription); Subscriptions.Remove(subscription); break; } }
public void Subscribe(NatsSubscription natsSubscription) { if (Subscriptions.ContainsKey(natsSubscription)) { return; } Logger.Info($"{nameof(Subscribe)}: {natsSubscription.Subject}"); List <IAsyncSubscription> subs = new List <IAsyncSubscription>(); foreach (var conn in ConnectionsByName.Values) { IAsyncSubscription sub = conn.SubscribeAsync(natsSubscription.Subject, OnMessage); subs.Add(sub); } Subscriptions[natsSubscription] = subs; natsSubscription.Subscribed = subs.Any(); Subscribed?.Invoke(natsSubscription); }
public void Remove(NatsSubscription natsSubscription) { Logger.Info($"Remove NatsSubject: {natsSubscription.Subject}"); Configuration.RemoveSubject(natsSubscription.Subject); Configuration.Save(NatsXml); }
public void Add(NatsSubscription subscription) { RemoveSubject(subscription.Subject); Subscriptions.Add(subscription); }
private void OnSelectedItemChanged(NatsSubscription subscription) { Model.Subject = subscription.Subject; InvokeAsync(StateHasChanged); }
private void Subscribe(NatsSubscription subscription) { Logger.Info($"{nameof(NatsSubscription.Subscribe)}: {subscription}"); NatsService.Subscribe(subscription); Subscriptions.Update(subscription); }