/// <summary> /// Ensure that the service description properties have been initialized /// for all service endpoints. /// </summary> /// <param name="map"></param> private static void VerifyInit(NeonServiceMap map) { foreach (var serviceDescription in map.Values) { foreach (var serviceEndpoint in serviceDescription.Endpoints.Values) { if (object.ReferenceEquals(serviceEndpoint, serviceDescription)) { throw new InvalidOperationException($"Service map entry for [{serviceDescription.Name}] has endpoint [{serviceEndpoint.Name}] that does not reference the correct parent description."); } } } }
/// <summary> /// Builds the <see cref="NeonServiceMap"/> for internal production services. /// </summary> private static void BuildProduction() { serviceMaps["production"] = new NeonServiceMap(); serviceMaps["production"].AddServiceDescription(NeonServices.ClusterManager, new ServiceEndpoint()); serviceMaps["production"].AddServiceDescription(NeonServices.Elasticsearch, new ServiceEndpoint() { Port = 9200 }, "monitoring"); serviceMaps["production"].AddServiceDescription(NeonServices.Kibana, new ServiceEndpoint() { Port = 5601 }, "monitoring"); serviceMaps["production"].AddServiceDescription(NeonServices.TestCadence, new ServiceEndpoint()); VerifyInit(Production); }
/// <summary> /// Clones a <see cref="NeonServiceMap"/> and changes the <see cref="ServiceDescription.Address"/> for each of the services. /// </summary> public static NeonServiceMap CloneWithNewAdress(NeonServiceMap map, string ip) { var newMap = NeonHelper.JsonClone <NeonServiceMap>(map); int port = 8300; foreach (var k in newMap.Keys) { newMap[k].Address = ip; if (!newMap[k].Endpoints.IsEmpty()) { newMap[k].Endpoints.Default.ServiceDescription = newMap[k]; if (newMap[k].Endpoints.Default.Port == 0) { newMap[k].Endpoints.Default.Port = port; port++; } } } VerifyInit(newMap); return(newMap); }