Skip to content

Commit

Permalink
Remove Schema related leftovers (#1263)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
d0x7 and scottf authored Dec 18, 2024
1 parent d841f65 commit 9c10628
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/nats/service/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/nats/service/ServiceBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class ServiceBuilder {
Duration drainTimeout = DEFAULT_DRAIN_TIMEOUT;
Dispatcher pingDispatcher;
Dispatcher infoDispatcher;
Dispatcher schemaDispatcher;
Dispatcher statsDispatcher;

/**
Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 2 additions & 5 deletions src/test/java/io/nats/service/ServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -424,7 +423,6 @@ public void testDispatchers() throws Exception {
.addServiceEndpoint(se1)
.pingDispatcher(dPing)
.infoDispatcher(dInfo)
.schemaDispatcher(dSchema)
.statsDispatcher(dStats)
.build();

Expand All @@ -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);
Expand Down

0 comments on commit 9c10628

Please sign in to comment.