Skip to content

Commit 76964cf

Browse files
refactor: change function name
1 parent ec22b57 commit 76964cf

File tree

4 files changed

+46
-19
lines changed

4 files changed

+46
-19
lines changed

src/main/java/com/influxdb/v3/client/internal/GrpcCallOptions.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ private GrpcCallOptions(@Nonnull final Builder builder) {
6060
this.callOptions = builder.callOptions.toArray(new CallOption[0]);
6161
}
6262

63+
64+
/**
65+
* Creates a default instance of {@link GrpcCallOptions} with predefined settings.
66+
* <p>
67+
* The default configuration includes:
68+
* <ul>
69+
* <li>Maximum inbound message size set to {@link Integer#MAX_VALUE}.</li>
70+
* </ul>
71+
* Other options can be customized using the {@link GrpcCallOptions.Builder}.
72+
*
73+
* @return the default configuration of {@link GrpcCallOptions}.
74+
*/
75+
public static GrpcCallOptions getDefaultOptions() {
76+
GrpcCallOptions.Builder builder = new GrpcCallOptions.Builder();
77+
builder.withMaxInboundMessageSize(Integer.MAX_VALUE);
78+
return builder.build();
79+
}
80+
6381
/**
6482
* Merges two arrays of {@link CallOption} into a single array. The method combines the elements
6583
* from the baseCallOptions array and the additional callOptions array. If either of the input

src/main/java/com/influxdb/v3/client/internal/InfluxDBClientImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ private Stream<VectorSchemaRoot> queryData(@Nonnull final String query,
342342
}
343343
});
344344

345-
CallOption[] callOptions = options.grpcCallOption() != null ? options.grpcCallOption().getCallOptions() : null;
345+
CallOption[] callOptions = options.grpcCallOptions() != null
346+
? options.grpcCallOptions().getCallOptions() : null;
346347
return flightSqlClient.execute(
347348
query,
348349
database,

src/main/java/com/influxdb/v3/client/query/QueryOptions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public final class QueryOptions {
6262
private final String database;
6363
private final QueryType queryType;
6464
private final Map<String, String> headers;
65-
private GrpcCallOptions grpcCallOption;
65+
private GrpcCallOptions grpcCallOptions = GrpcCallOptions.getDefaultOptions();
6666

6767
/**
6868
* Construct QueryAPI options. The query type is set to SQL.
@@ -148,18 +148,18 @@ public Map<String, String> headersSafe() {
148148

149149
/**
150150
* Sets the GrpcCallOptions object.
151-
* @param grpcCallOption the grpcCallOption
151+
* @param grpcCallOptions the grpcCallOptions
152152
*/
153-
public void setGrpcCallOption(@Nonnull final GrpcCallOptions grpcCallOption) {
154-
this.grpcCallOption = grpcCallOption;
153+
public void setGrpcCallOptions(@Nonnull final GrpcCallOptions grpcCallOptions) {
154+
this.grpcCallOptions = grpcCallOptions;
155155
}
156156

157157
/**
158158
* @return the GrpcCallOptions object.
159159
*/
160160
@Nullable
161-
public GrpcCallOptions grpcCallOption() {
162-
return grpcCallOption;
161+
public GrpcCallOptions grpcCallOptions() {
162+
return grpcCallOptions;
163163
}
164164

165165
private boolean isNotDefined(final String option) {

src/test/java/com/influxdb/v3/client/query/QueryOptionsTest.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void setInboundMessageSizeSmall() throws Exception {
128128
.build();
129129

130130
QueryOptions queryOptions = new QueryOptions("test");
131-
queryOptions.setGrpcCallOption(grpcCallOption);
131+
queryOptions.setGrpcCallOptions(grpcCallOption);
132132

133133
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(builder.build())) {
134134
try (Stream<PointValues> stream = influxDBClient.queryPoints(
@@ -166,7 +166,7 @@ void setInboundMessageSizeLarge() throws Exception {
166166
.build();
167167

168168
QueryOptions queryOptions = new QueryOptions("test");
169-
queryOptions.setGrpcCallOption(grpcCallOption);
169+
queryOptions.setGrpcCallOptions(grpcCallOption);
170170

171171
try (InfluxDBClient influxDBClient = InfluxDBClient.getInstance(clientConfig)) {
172172
Assertions.assertThatNoException().isThrownBy(() -> {
@@ -181,7 +181,15 @@ void setInboundMessageSizeLarge() throws Exception {
181181
}
182182

183183
@Test
184-
void setGrpcCallOption() {
184+
void defaultGrpcCallOptions() {
185+
GrpcCallOptions grpcCallOptions = new QueryOptions("test").grpcCallOptions();
186+
Assertions.assertThat(grpcCallOptions).isNotNull();
187+
Assertions.assertThat(grpcCallOptions.getMaxInboundMessageSize()).isEqualTo(Integer.MAX_VALUE);
188+
Assertions.assertThat(grpcCallOptions.getCallOptions().length).isEqualTo(1);
189+
}
190+
191+
@Test
192+
void setGrpcCallOptions() {
185193
Executor executor = Executors.newSingleThreadExecutor();
186194
Deadline deadline = Deadline.after(2, TimeUnit.SECONDS);
187195
String compressorName = "name";
@@ -195,19 +203,19 @@ void setGrpcCallOption() {
195203
.build();
196204

197205
QueryOptions options = new QueryOptions("test");
198-
options.setGrpcCallOption(grpcCallOption);
199-
Assertions.assertThat(options.grpcCallOption()).isNotNull();
200-
Assertions.assertThat(options.grpcCallOption().getMaxInboundMessageSize()).isEqualTo(1024);
201-
Assertions.assertThat(options.grpcCallOption().getMaxOutboundMessageSize()).isEqualTo(1024);
202-
Assertions.assertThat(options.grpcCallOption().getExecutor()).isEqualTo(executor);
203-
Assertions.assertThat(options.grpcCallOption().getWaitForReady()).isTrue();
204-
Assertions.assertThat(options.grpcCallOption().getCompressorName()).isEqualTo(compressorName);
205-
Assertions.assertThat(options.grpcCallOption().getDeadline()).isEqualTo(deadline);
206+
options.setGrpcCallOptions(grpcCallOption);
207+
Assertions.assertThat(options.grpcCallOptions()).isNotNull();
208+
Assertions.assertThat(options.grpcCallOptions().getMaxInboundMessageSize()).isEqualTo(1024);
209+
Assertions.assertThat(options.grpcCallOptions().getMaxOutboundMessageSize()).isEqualTo(1024);
210+
Assertions.assertThat(options.grpcCallOptions().getExecutor()).isEqualTo(executor);
211+
Assertions.assertThat(options.grpcCallOptions().getWaitForReady()).isTrue();
212+
Assertions.assertThat(options.grpcCallOptions().getCompressorName()).isEqualTo(compressorName);
213+
Assertions.assertThat(options.grpcCallOptions().getDeadline()).isEqualTo(deadline);
206214

207215
}
208216

209217
@Test
210-
void grpcCallOption() {
218+
void grpcCallOptions() {
211219
Executor executor = Executors.newSingleThreadExecutor();
212220
Deadline deadline = Deadline.after(2, TimeUnit.SECONDS);
213221
GrpcCallOptions grpcCallOption = new GrpcCallOptions.Builder()

0 commit comments

Comments
 (0)