private static Probe GetProbeFromBuilder(ProbeBuilder builder) => new Probe() { Http = builder.Http != null ? new HttpProber() { Path = builder.Http.Path, Headers = builder.Http.Headers, Port = builder.Http.Port, Protocol = builder.Http.Protocol } : null, InitialDelay = TimeSpan.FromSeconds(builder.InitialDelay), Period = TimeSpan.FromSeconds(builder.Period), Timeout = TimeSpan.FromSeconds(builder.Timeout), SuccessThreshold = builder.SuccessThreshold, FailureThreshold = builder.FailureThreshold };
private static void AddProbe(ServiceBuilder service, YamlMappingNode container, ProbeBuilder builder, string probeName) { var probe = new YamlMappingNode(); container.Add(probeName, probe); if (builder.Http != null) { var builderHttp = builder.Http; var httpGet = new YamlMappingNode(); probe.Add("httpGet", httpGet); httpGet.Add("path", builderHttp.Path); if (builderHttp.Protocol != null) { httpGet.Add("scheme", builderHttp.Protocol.ToUpper()); } if (builderHttp.Port != null) { httpGet.Add("port", builderHttp.Port.ToString() !); } else { // If port is not given, we pull default port var binding = service.Bindings.First(b => builderHttp.Protocol == null || b.Protocol == builderHttp.Protocol); if (binding.Port != null) { httpGet.Add("port", binding.Port.Value.ToString()); } if (builderHttp.Protocol == null && binding.Protocol != null) { httpGet.Add("scheme", binding.Protocol.ToUpper()); } } if (builderHttp.Headers.Count > 0) { var headers = new YamlSequenceNode(); httpGet.Add("httpHeaders", headers); foreach (var(name, value) in builderHttp.Headers) { var header = new YamlMappingNode { { "name", name },
private static void AddProbe(ServiceBuilder service, YamlMappingNode container, ProbeBuilder builder, string name) { var probe = new YamlMappingNode(); container.Add(name, probe); if (builder.Http != null) { var builderHttp = builder.Http; var httpGet = new YamlMappingNode(); probe.Add("httpGet", httpGet); httpGet.Add("path", builderHttp.Path); if (builderHttp.Protocol != null) { httpGet.Add("scheme", builderHttp.Protocol.ToUpper()); } if (builderHttp.Port != null) { httpGet.Add("port", builderHttp.Port.ToString() !); } else { // If port is not given, we pull default port var binding = service.Bindings.First(b => builderHttp.Protocol == null || b.Protocol == builderHttp.Protocol); if (binding.Port != null) { httpGet.Add("port", binding.Port.Value.ToString()); } if (builderHttp.Protocol == null && binding.Protocol != null) { httpGet.Add("scheme", binding.Protocol.ToUpper()); } } if (builderHttp.Headers.Count > 0) { var headers = new YamlSequenceNode(); httpGet.Add("httpHeaders", headers); foreach (var builderHeader in builderHttp.Headers) { var header = new YamlMappingNode(); header.Add("name", builderHeader.Key); header.Add("value", builderHeader.Value.ToString() !); headers.Add(header); } } } probe.Add("initialDelaySeconds", builder.InitialDelay.ToString()); probe.Add("periodSeconds", builder.Period.ToString() !); probe.Add("successThreshold", builder.SuccessThreshold.ToString() !); probe.Add("failureThreshold", builder.FailureThreshold.ToString() !); }