/// <summary> /// Initializes a new instance of the <see cref="SwaggerDescriptionActor"/> class. /// </summary> public SwaggerDescriptionActor() { var publishDocUrl = Context.System.Settings.Config.GetString("ClusterKit.Web.Swagger.Publish.publishDocPath", "swagger"); var publishUiUrl = Context.System.Settings.Config.GetString("ClusterKit.Web.Swagger.Publish.publishUiPath", "swagger/ui"); this.description = new SwaggerPublishDescription { Url = publishUiUrl, DocUrl = publishDocUrl }; Cluster.Get(Context.System) .Subscribe( this.Self, ClusterEvent.InitialStateAsEvents, typeof(ClusterEvent.MemberUp)); this.Receive<ClusterEvent.MemberUp>( m => m.Member.Roles.Contains("Web.Swagger.Monitor"), m => this.OnNodeUp(m.Member.Address)); this.Receive<SwaggerPublishDescriptionRequest>(m => this.OnNodeDescriptionRequest()); }
/// <summary> /// Processes <seealso cref="SwaggerPublishDescription"/> message from Swagger node /// </summary> /// <param name="description">The message, containing swagger publication definition </param> private void OnNodeDescription(SwaggerPublishDescription description) { bool collectionModified = false; var address = this.Sender.Path.Address; string oldUrl; if (this.publishedUrls.TryGetValue(address, out oldUrl)) { if (oldUrl != description.Url) { collectionModified = !this.publishedUrls.Values.Contains(description.Url); this.publishedUrls[address] = description.Url; collectionModified = collectionModified || !this.publishedUrls.Values.Contains(oldUrl); } } else { collectionModified = !this.publishedUrls.Values.Contains(description.Url); this.publishedUrls[address] = description.Url; } if (collectionModified) { this.UpdateWorkers(); } }