From 9c10628aa92cc715c06f1fdc3cf15dfad1c754bb Mon Sep 17 00:00:00 2001 From: Dorian Heinrichs Date: Wed, 18 Dec 2024 19:26:54 +0100 Subject: [PATCH] Remove Schema related leftovers (#1263) * Remove Schema related leftovers Closes #1262 * Undo removal of spec breaking changes * Added @Deprecated annotation * Update ServiceTests.java * Update ServiceTests.java --------- Co-authored-by: Scott Fauerbach --- README.md | 2 +- src/main/java/io/nats/service/Service.java | 3 +-- src/main/java/io/nats/service/ServiceBuilder.java | 6 +++--- src/test/java/io/nats/service/ServiceTests.java | 7 ++----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 007c3a5a6..54423be2b 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ The service API allows you to easily build NATS services. The Service Framework The Services Framework introduces a higher-level API for implementing services with NATS. NATS has always been a strong technology on which to build services, as they are easy to write, are location and DNS independent and can be scaled up or down by simply adding or removing instances of the service. -The Services Framework further streamlines their development by providing observability and standardization. The Service Framework allows your services to be discovered, queried for status and schema information without additional work. +The Services Framework further streamlines their development by providing observability and standardization. The Service Framework allows your services to be discovered and queried for status without additional work. Check out the [ServiceExample](src/examples/java/io/nats/examples/service/ServiceExample.java) diff --git a/src/main/java/io/nats/service/Service.java b/src/main/java/io/nats/service/Service.java index 0ed56dc66..e335a6072 100644 --- a/src/main/java/io/nats/service/Service.java +++ b/src/main/java/io/nats/service/Service.java @@ -65,7 +65,6 @@ public class Service { // set up the service contexts // ? do we need an internal dispatcher for any user endpoints - // ! also while we are here, we need to collect the endpoints for the SchemaResponse Dispatcher dTemp = null; serviceContexts = new HashMap<>(); for (ServiceEndpoint se : b.serviceEndpoints.values()) { @@ -87,7 +86,7 @@ public class Service { pingResponse = new PingResponse(id, b.name, b.version, b.metadata); infoResponse = new InfoResponse(id, b.name, b.version, b.metadata, b.description, b.serviceEndpoints.values()); - if (b.pingDispatcher == null || b.infoDispatcher == null || b.schemaDispatcher == null || b.statsDispatcher == null) { + if (b.pingDispatcher == null || b.infoDispatcher == null || b.statsDispatcher == null) { dTemp = conn.createDispatcher(); dInternals.add(dTemp); } diff --git a/src/main/java/io/nats/service/ServiceBuilder.java b/src/main/java/io/nats/service/ServiceBuilder.java index 59fd6e824..f61778bf4 100644 --- a/src/main/java/io/nats/service/ServiceBuilder.java +++ b/src/main/java/io/nats/service/ServiceBuilder.java @@ -26,7 +26,6 @@ public class ServiceBuilder { Duration drainTimeout = DEFAULT_DRAIN_TIMEOUT; Dispatcher pingDispatcher; Dispatcher infoDispatcher; - Dispatcher schemaDispatcher; Dispatcher statsDispatcher; /** @@ -130,12 +129,13 @@ public ServiceBuilder infoDispatcher(Dispatcher infoDispatcher) { } /** - * Optional dispatcher for the schema service + * A NOOP method to maintain compatibility with the old schema dispatcher, superseded by endpointMetadata + * @deprecated No longer used, see {@link ServiceEndpoint.Builder#endpointMetadata(Map)} instead * @param schemaDispatcher the dispatcher * @return the ServiceBuilder */ + @Deprecated public ServiceBuilder schemaDispatcher(Dispatcher schemaDispatcher) { - this.schemaDispatcher = schemaDispatcher; return this; } diff --git a/src/test/java/io/nats/service/ServiceTests.java b/src/test/java/io/nats/service/ServiceTests.java index b487817e7..b7cc99e48 100644 --- a/src/test/java/io/nats/service/ServiceTests.java +++ b/src/test/java/io/nats/service/ServiceTests.java @@ -404,12 +404,11 @@ public void testDispatchers() throws Exception { Dispatcher dPing = nc.createDispatcher(); Dispatcher dInfo = nc.createDispatcher(); - Dispatcher dSchema = nc.createDispatcher(); Dispatcher dStats = nc.createDispatcher(); Dispatcher dEnd = nc.createDispatcher(); dispatchers = getDispatchers(nc); - assertEquals(5, dispatchers.size()); + assertEquals(4, dispatchers.size()); ServiceEndpoint se1 = ServiceEndpoint.builder() .endpointName("dispatch") @@ -424,7 +423,6 @@ public void testDispatchers() throws Exception { .addServiceEndpoint(se1) .pingDispatcher(dPing) .infoDispatcher(dInfo) - .schemaDispatcher(dSchema) .statsDispatcher(dStats) .build(); @@ -434,11 +432,10 @@ public void testDispatchers() throws Exception { done.get(100, TimeUnit.MILLISECONDS); dispatchers = getDispatchers(nc); - assertEquals(5, dispatchers.size()); // stop doesn't touch supplied dispatchers + assertEquals(4, dispatchers.size()); // stop doesn't touch supplied dispatchers nc.closeDispatcher(dPing); nc.closeDispatcher(dInfo); - nc.closeDispatcher(dSchema); sleep(100); // no rush dispatchers = getDispatchers(nc);