Skip to content

Commit 43ece3f

Browse files
authored
Merge branch 'main' into fix-proxy-hostname-resolution
2 parents 3480c05 + df9efbc commit 43ece3f

File tree

12 files changed

+19
-499
lines changed

12 files changed

+19
-499
lines changed

src/examples/java/io/nats/examples/service/ServiceExample.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public static void main(String[] args) throws IOException {
4545
Endpoint epEcho = Endpoint.builder()
4646
.name("EchoEndpoint")
4747
.subject("echo")
48-
.schemaRequest("echo schema request info") // optional
49-
.schemaResponse("echo schema response info") // optional
5048
.build();
5149

5250
// Sort is going to be grouped. This will affect the actual subject
@@ -71,8 +69,6 @@ public static void main(String[] args) throws IOException {
7169
.group(sortGroup)
7270
.endpointName("SortEndpointAscending")
7371
.endpointSubject("ascending")
74-
.endpointSchemaRequest("sort ascending schema request info") // optional
75-
.endpointSchemaResponse("sort ascending schema response info") // optional
7672
.handler(msg -> handleSortAscending(nc, msg, "S1A"))
7773
.build();
7874

@@ -88,7 +84,6 @@ public static void main(String[] args) throws IOException {
8884
Service service1 = new ServiceBuilder()
8985
.connection(nc)
9086
.name("Service1")
91-
.apiUrl("Service1 Api Url") // optional
9287
.description("Service1 Description") // optional
9388
.version("0.0.1")
9489
.addServiceEndpoint(seEcho1)
@@ -122,7 +117,7 @@ public static void main(String[] args) throws IOException {
122117
String subject = "echo";
123118
CompletableFuture<Message> reply = nc.request(subject, request.getBytes());
124119
String response = new String(reply.get().getData());
125-
System.out.println("" + x + ". Called " + subject + " with [" + request + "] Received " + response);
120+
System.out.println(x + ". Called " + subject + " with [" + request + "] Received " + response);
126121
}
127122

128123
// sort subjects are formed this way because the endpoints have groups
@@ -165,18 +160,6 @@ public static void main(String[] args) throws IOException {
165160
infoResponses = discovery.info("Service2");
166161
printDiscovery("Info", "Service2", infoResponses);
167162

168-
// ----------------------------------------------------------------------------------------------------
169-
// schema discover variations
170-
// ----------------------------------------------------------------------------------------------------
171-
List<SchemaResponse> schemaResponsList = discovery.schema();
172-
printDiscovery("Schema", "[All]", schemaResponsList);
173-
174-
schemaResponsList = discovery.schema("Service1");
175-
printDiscovery("Schema", "Service1", schemaResponsList);
176-
177-
schemaResponsList = discovery.schema("Service2");
178-
printDiscovery("Schema", "Service2", schemaResponsList);
179-
180163
// ----------------------------------------------------------------------------------------------------
181164
// stats discover variations
182165
// ----------------------------------------------------------------------------------------------------

src/main/java/io/nats/service/Discovery.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,6 @@ public InfoResponse info(String serviceName, String serviceId) {
8989
return jsonBytes == null ? null : new InfoResponse(jsonBytes);
9090
}
9191

92-
// ----------------------------------------------------------------------------------------------------
93-
// schema
94-
// ----------------------------------------------------------------------------------------------------
95-
public List<SchemaResponse> schema() {
96-
return schema(null);
97-
}
98-
99-
public List<SchemaResponse> schema(String serviceName) {
100-
List<SchemaResponse> list = new ArrayList<>();
101-
discoverMany(SRV_SCHEMA, serviceName, jsonBytes -> list.add(new SchemaResponse(jsonBytes)));
102-
return list;
103-
}
104-
105-
public SchemaResponse schema(String serviceName, String serviceId) {
106-
byte[] jsonBytes = discoverOne(SRV_SCHEMA, serviceName, serviceId);
107-
return jsonBytes == null ? null : new SchemaResponse(jsonBytes);
108-
}
109-
11092
// ----------------------------------------------------------------------------------------------------
11193
// stats
11294
// ----------------------------------------------------------------------------------------------------

src/main/java/io/nats/service/Endpoint.java

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
import static io.nats.client.support.ApiConstants.*;
2424
import static io.nats.client.support.JsonUtils.endJson;
25-
import static io.nats.client.support.JsonValueUtils.*;
25+
import static io.nats.client.support.JsonValueUtils.readString;
26+
import static io.nats.client.support.JsonValueUtils.readStringStringMap;
2627
import static io.nats.client.support.Validator.validateIsRestrictedTerm;
2728
import static io.nats.client.support.Validator.validateSubject;
2829

@@ -32,27 +33,18 @@
3233
public class Endpoint implements JsonSerializable {
3334
private final String name;
3435
private final String subject;
35-
private final Schema schema;
3636
private final Map<String, String> metadata;
3737

38-
public Endpoint(String name, String subject, Schema schema) {
39-
this(name, subject, schema, null, true);
40-
}
41-
4238
public Endpoint(String name) {
43-
this(name, null, null, null, true);
39+
this(name, null, null, true);
4440
}
4541

4642
public Endpoint(String name, String subject) {
47-
this(name, subject, null, null, true);
48-
}
49-
50-
public Endpoint(String name, String subject, String schemaRequest, String schemaResponse) {
51-
this(name, subject, Schema.optionalInstance(schemaRequest, schemaResponse), null, true);
43+
this(name, subject, null, true);
5244
}
5345

5446
// internal use constructors
55-
Endpoint(String name, String subject, Schema schema, Map<String, String> metadata, boolean validate) {
47+
Endpoint(String name, String subject, Map<String, String> metadata, boolean validate) {
5648
if (validate) {
5749
this.name = validateIsRestrictedTerm(name, "Endpoint Name", true);
5850
if (subject == null) {
@@ -66,27 +58,24 @@ public Endpoint(String name, String subject, String schemaRequest, String schema
6658
this.name = name;
6759
this.subject = subject;
6860
}
69-
this.schema = schema;
7061
this.metadata = metadata == null || metadata.size() == 0 ? null : metadata;
7162
}
7263

7364
Endpoint(JsonValue vEndpoint) {
7465
name = readString(vEndpoint, NAME);
7566
subject = readString(vEndpoint, SUBJECT);
76-
schema = Schema.optionalInstance(readValue(vEndpoint, SCHEMA));
7767
metadata = readStringStringMap(vEndpoint, METADATA);
7868
}
7969

8070
Endpoint(Builder b) {
81-
this(b.name, b.subject, Schema.optionalInstance(b.schemaRequest, b.schemaResponse), b.metadata, true);
71+
this(b.name, b.subject, b.metadata, true);
8272
}
8373

8474
@Override
8575
public String toJson() {
8676
StringBuilder sb = JsonUtils.beginJson();
8777
JsonUtils.addField(sb, NAME, name);
8878
JsonUtils.addField(sb, SUBJECT, subject);
89-
JsonUtils.addField(sb, SCHEMA, schema);
9079
JsonUtils.addField(sb, METADATA, metadata);
9180
return endJson(sb).toString();
9281
}
@@ -104,10 +93,6 @@ public String getSubject() {
10493
return subject;
10594
}
10695

107-
public Schema getSchema() {
108-
return schema;
109-
}
110-
11196
public Map<String, String> getMetadata() {
11297
return metadata;
11398
}
@@ -119,22 +104,11 @@ public static Builder builder() {
119104
public static class Builder {
120105
private String name;
121106
private String subject;
122-
private String schemaRequest;
123-
private String schemaResponse;
124107
private Map<String, String> metadata;
125108

126109
public Builder endpoint(Endpoint endpoint) {
127110
name = endpoint.getName();
128111
subject = endpoint.getSubject();
129-
Schema s = endpoint.getSchema();
130-
if (s == null) {
131-
schemaRequest = null;
132-
schemaResponse = null;
133-
}
134-
else {
135-
schemaRequest = s.getRequest();
136-
schemaResponse = s.getResponse();
137-
}
138112
return this;
139113
}
140114

@@ -148,28 +122,6 @@ public Builder subject(String subject) {
148122
return this;
149123
}
150124

151-
public Builder schemaRequest(String schemaRequest) {
152-
this.schemaRequest = schemaRequest;
153-
return this;
154-
}
155-
156-
public Builder schemaResponse(String schemaResponse) {
157-
this.schemaResponse = schemaResponse;
158-
return this;
159-
}
160-
161-
public Builder schema(Schema schema) {
162-
if (schema == null) {
163-
schemaRequest = null;
164-
schemaResponse = null;
165-
}
166-
else {
167-
schemaRequest = schema.getRequest();
168-
schemaResponse = schema.getResponse();
169-
}
170-
return this;
171-
}
172-
173125
public Builder metadata(Map<String, String> metadata) {
174126
this.metadata = metadata;
175127
return this;
@@ -189,15 +141,13 @@ public boolean equals(Object o) {
189141

190142
if (!Objects.equals(name, that.name)) return false;
191143
if (!Objects.equals(subject, that.subject)) return false;
192-
if (!Objects.equals(schema, that.schema)) return false;
193144
return JsonUtils.mapEquals(metadata, that.metadata);
194145
}
195146

196147
@Override
197148
public int hashCode() {
198149
int result = name != null ? name.hashCode() : 0;
199150
result = 31 * result + (subject != null ? subject.hashCode() : 0);
200-
result = 31 * result + (schema != null ? schema.hashCode() : 0);
201151
result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
202152
return result;
203153
}

src/main/java/io/nats/service/EndpointResponse.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
public class EndpointResponse implements JsonSerializable {
3434
private final String name;
3535
private final String subject;
36-
private final Schema schema;
3736
private final long numRequests;
3837
private final long numErrors;
3938
private final long processingTime;
@@ -50,7 +49,6 @@ static List<EndpointResponse> listOf(JsonValue vEndpointStats) {
5049
EndpointResponse(String name, String subject, long numRequests, long numErrors, long processingTime, String lastError, JsonValue data, ZonedDateTime started) {
5150
this.name = name;
5251
this.subject = subject;
53-
this.schema = null;
5452
this.numRequests = numRequests;
5553
this.numErrors = numErrors;
5654
this.processingTime = processingTime;
@@ -61,10 +59,9 @@ static List<EndpointResponse> listOf(JsonValue vEndpointStats) {
6159
}
6260

6361
// This is for schema
64-
EndpointResponse(String name, String subject, Schema schema) {
62+
EndpointResponse(String name, String subject) {
6563
this.name = name;
6664
this.subject = subject;
67-
this.schema = schema;
6865
this.numRequests = 0;
6966
this.numErrors = 0;
7067
this.processingTime = 0;
@@ -77,7 +74,6 @@ static List<EndpointResponse> listOf(JsonValue vEndpointStats) {
7774
EndpointResponse(JsonValue vEndpointResponse) {
7875
name = readString(vEndpointResponse, NAME);
7976
subject = readString(vEndpointResponse, SUBJECT);
80-
schema = Schema.optionalInstance(readValue(vEndpointResponse, SCHEMA));
8177
numRequests = readLong(vEndpointResponse, NUM_REQUESTS, 0);
8278
numErrors = readLong(vEndpointResponse, NUM_ERRORS, 0);
8379
processingTime = readLong(vEndpointResponse, PROCESSING_TIME, 0);
@@ -92,7 +88,6 @@ public String toJson() {
9288
StringBuilder sb = beginJson();
9389
JsonUtils.addField(sb, NAME, name);
9490
JsonUtils.addField(sb, SUBJECT, subject);
95-
JsonUtils.addField(sb, SCHEMA, schema);
9691
JsonUtils.addFieldWhenGtZero(sb, NUM_REQUESTS, numRequests);
9792
JsonUtils.addFieldWhenGtZero(sb, NUM_ERRORS, numErrors);
9893
JsonUtils.addFieldWhenGtZero(sb, PROCESSING_TIME, processingTime);
@@ -111,10 +106,6 @@ public String getSubject() {
111106
return subject;
112107
}
113108

114-
public Schema getSchema() {
115-
return schema;
116-
}
117-
118109
public long getNumRequests() {
119110
return numRequests;
120111
}
@@ -161,7 +152,6 @@ public boolean equals(Object o) {
161152
if (averageProcessingTime != that.averageProcessingTime) return false;
162153
if (!Objects.equals(name, that.name)) return false;
163154
if (!Objects.equals(subject, that.subject)) return false;
164-
if (!Objects.equals(schema, that.schema)) return false;
165155
if (!Objects.equals(lastError, that.lastError)) return false;
166156
if (!Objects.equals(data, that.data)) return false;
167157
return Objects.equals(started, that.started);
@@ -171,7 +161,6 @@ public boolean equals(Object o) {
171161
public int hashCode() {
172162
int result = name != null ? name.hashCode() : 0;
173163
result = 31 * result + (subject != null ? subject.hashCode() : 0);
174-
result = 31 * result + (schema != null ? schema.hashCode() : 0);
175164
result = 31 * result + (int) (numRequests ^ (numRequests >>> 32));
176165
result = 31 * result + (int) (numErrors ^ (numErrors >>> 32));
177166
result = 31 * result + (int) (processingTime ^ (processingTime >>> 32));

0 commit comments

Comments
 (0)