From e231034baf10cb6c038c2d64d385f6993125ea7d Mon Sep 17 00:00:00 2001 From: aiyyo Date: Wed, 11 Sep 2019 16:29:19 +0200 Subject: [PATCH 1/3] Since Consul 1.0 the GET method is not allowed to deregister the service. https://github.com/hashicorp/consul/issues/3659#issuecomment-342519570 --- src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs b/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs index a85b304..f4e770e 100644 --- a/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs +++ b/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs @@ -73,7 +73,8 @@ public static void RegisterService(ServiceRegistration registration) /// throws exception if unregistering was not successful public static void UnregisterService(string serviceId) { - ConsulUris.DeregisterService(serviceId).GetJsonFromUrl( + ConsulUris.DeregisterService(serviceId).PutJsonToUrl( + null, null, response => { @@ -205,4 +206,4 @@ private static ConsulServiceResponse[] GetConsulServiceResponses(string response return health.Select(ConsulServiceResponse.Create).ToArray(); } } -} \ No newline at end of file +} From 9dcf6a73ae372a0fb21274380b7963c2ca563c05 Mon Sep 17 00:00:00 2001 From: aiyyo Date: Wed, 11 Sep 2019 16:42:11 +0200 Subject: [PATCH 2/3] ServiceStack v5.4 compatible custom JSConfig declaration https://docs.servicestack.net/releases/v5.4#custom-scopes This commit fix this issue too: https://github.com/wwwlicious/servicestack-discovery-consul/issues/29 --- src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs b/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs index f4e770e..1da9d9e 100644 --- a/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs +++ b/src/Servicestack.Discovery.Consul/Consul/ConsulClient.cs @@ -37,10 +37,8 @@ public static void RegisterService(ServiceRegistration registration) ServiceValidator.ValidateAndThrow(consulServiceRegistration); var registrationUrl = ConsulFeature.ConsulAgentResolver.CombineWith(consulServiceRegistration.ToPutUrl()); - using (var config = JsConfig.BeginScope()) + using (JsConfig.With(new Config { TextCase = TextCase.Default, IncludeNullValues = false })) { - config.EmitCamelCaseNames = false; - config.IncludeNullValues = false; registrationUrl.PutJsonToUrl(consulServiceRegistration, null, response => { @@ -169,11 +167,8 @@ public static void RegisterHealthChecks(params ServiceHealthCheck[] healthChecks }; HealthcheckValidator.ValidateAndThrow(consulCheck); - using (var config = JsConfig.BeginScope()) + using (JsConfig.With(new Config { TextCase = TextCase.Default, IncludeNullValues = false })) { - config.EmitCamelCaseNames = false; - config.IncludeNullValues = false; - ConsulFeature.ConsulAgentResolver.CombineWith(consulCheck.ToPutUrl()).PutJsonToUrl( consulCheck, null, From aba636131847c8795c76619ef14b3c9359bc85f8 Mon Sep 17 00:00:00 2001 From: aiyyo Date: Wed, 11 Sep 2019 17:07:13 +0200 Subject: [PATCH 3/3] ServiceStack.Server version update to 5.4.0 --- .../ServiceStack.Discovery.Consul.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Servicestack.Discovery.Consul/ServiceStack.Discovery.Consul.csproj b/src/Servicestack.Discovery.Consul/ServiceStack.Discovery.Consul.csproj index 30d205a..f784795 100644 --- a/src/Servicestack.Discovery.Consul/ServiceStack.Discovery.Consul.csproj +++ b/src/Servicestack.Discovery.Consul/ServiceStack.Discovery.Consul.csproj @@ -40,9 +40,9 @@ - + - \ No newline at end of file +