/
ClientOptions.java
309 lines (269 loc) · 7.54 KB
/
ClientOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
/*
* Copyright 2020 Confluent Inc.
*
* Licensed under the Confluent Community License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.confluent.io/confluent-community-license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.confluent.ksql.api.client;
import io.confluent.ksql.api.client.impl.ClientOptionsImpl;
import java.util.Map;
/**
* Options for the ksqlDB {@link Client}.
*/
public interface ClientOptions {
String DEFAULT_HOST = "localhost";
int DEFAULT_HOST_PORT = 8088;
int DEFAULT_EXECUTE_QUERY_MAX_RESULT_ROWS = 10000;
int DEFAULT_HTTP2_MULTIPLEXING_LIMIT = -1;
/**
* Sets the host name of the ksqlDB server to connect to. Defaults to "localhost".
*
* @param host host name
* @return a reference to this
*/
ClientOptions setHost(String host);
/**
* Sets the host port of the ksqlDB server to connect to. Defaults to 8088.
*
* @param port host port
* @return a reference to this
*/
ClientOptions setPort(int port);
/**
* Sets whether TLS should be used when connecting to the ksqlDB server. Defaults to false.
*
* @param useTls whether TLS should be used
* @return a reference to this
*/
ClientOptions setUseTls(boolean useTls);
/**
* Sets whether hostname verification (for TLS) is enabled. Defaults to true.
*
* @param verifyHost whether hostname verification should be enabled
* @return a reference to this
*/
ClientOptions setVerifyHost(boolean verifyHost);
/**
* Sets whether ALPN should be used. Defaults to false.
*
* @param useAlpn whether ALPN should be used
* @return a reference to this
*/
ClientOptions setUseAlpn(boolean useAlpn);
/**
* Sets the trust store path.
*
* @param trustStorePath trust store path
* @return a reference to this
*/
ClientOptions setTrustStore(String trustStorePath);
/**
* Sets the trust store password.
*
* @param trustStorePassword trust store password
* @return a reference to this
*/
ClientOptions setTrustStorePassword(String trustStorePassword);
/**
* Sets the key store path.
*
* @param keyStorePath key store path
* @return a reference to this
*/
ClientOptions setKeyStore(String keyStorePath);
/**
* Sets the key store password.
*
* @param keyStorePassword key store password
* @return a reference to this
*/
ClientOptions setKeyStorePassword(String keyStorePassword);
/**
* Sets the key password.
*
* @param keyPassword key password
* @return a reference to this
*/
ClientOptions setKeyPassword(String keyPassword);
/**
* Sets the key alias.
*
* @param keyAlias key alias
* @return a reference to this
*/
ClientOptions setKeyAlias(String keyAlias);
/**
* Sets key/trust store type.
*
* @param storeType store type
* @return a reference to this
*/
ClientOptions setStoreType(String storeType);
/**
* Sets the username and password to be used for HTTP basic authentication when connecting to the
* ksqlDB server. Basic authentication will be used unless both username and password are null
* (the default).
*
* @param username username for basic authentication
* @param password password for basic authentication
* @return a reference to this
*/
ClientOptions setBasicAuthCredentials(String username, String password);
/**
* Sets the maximum number of rows that may be returned in a {@link BatchedQueryResult}. Defaults
* to 10000.
*
* @param maxRows number of rows
* @return a reference to this
*/
ClientOptions setExecuteQueryMaxResultRows(int maxRows);
/**
* Sets the maximum number of requests per HTTP/2 connection. Defaults to -1.
*
* @param http2MultiplexingLimit number of requests
* @return a reference to this
*/
ClientOptions setHttp2MultiplexingLimit(int http2MultiplexingLimit);
/**
* Sets custom request headers to be sent with requests to the ksqlDB server.
* These headers are in addition to any automatic headers such as the
* authorization header.
*
* <p>If this method is called more than once, only the headers passed on
* the last invocation will be used. To update existing custom headers,
* use this method in combination with {@link ClientOptions#getRequestHeaders()}.
*
* <p>In case of overlap between these custom headers and automatic headers such
* as the authorization header, these custom headers take precedence.
*
* @param requestHeaders custom request headers
* @return a reference to this
*/
ClientOptions setRequestHeaders(Map<String, String> requestHeaders);
/**
* Returns the host name of the ksqlDB server to connect to.
*
* @return host name
*/
String getHost();
/**
* Returns the host port of the ksqlDB server to connect to.
*
* @return host port
*/
int getPort();
/**
* Returns whether TLS should be used when connecting to the ksqlDB server.
*
* @return whether TLS should be used
*/
boolean isUseTls();
/**
* Returns whether hostname verification (for TLS) is enabled.
*
* @return whether hostname verification is enabled
*/
boolean isVerifyHost();
/**
* Returns whether ALPN should be used.
*
* @return whether ALPN should be used
*/
boolean isUseAlpn();
/**
* Returns whether HTTP basic authentication will be used when connecting to the ksqlDB server.
*
* @return whether basic authentication will be used
*/
boolean isUseBasicAuth();
/**
* Returns the trust store path.
*
* @return trust store path
*/
String getTrustStore();
/**
* Returns the trust store password.
*
* @return trust store password
*/
String getTrustStorePassword();
/**
* Returns the key store path.
*
* @return key store path
*/
String getKeyStore();
/**
* Returns the key store password.
*
* @return key store password
*/
String getKeyStorePassword();
/**
* Returns the key password.
*
* @return key password
*/
String getKeyPassword();
/**
* Returns the key alias.
*
* @return key alias
*/
String getKeyAlias();
/**
* Returns the store type.
*
* @return key/trust store type
*/
String getStoreType();
/**
* Returns the username to be used for HTTP basic authentication, if applicable.
*
* @return username
*/
String getBasicAuthUsername();
/**
* Returns the password to be used for HTTP basic authentication, if applicable.
*
* @return password
*/
String getBasicAuthPassword();
/**
* Returns the maximum number of rows that may be returned in a {@link BatchedQueryResult}.
*
* @return number of rows
*/
int getExecuteQueryMaxResultRows();
/**
* Returns the maximum number of requests per HTTP/2 connection.
*
* @return number of requests
*/
int getHttp2MultiplexingLimit();
/**
* Returns a copy of the custom request headers to be sent with ksqlDB requests.
* If not set, then this method returns an empty map.
*
* @return custom request headers
*/
Map<String, String> getRequestHeaders();
/**
* Creates a copy of these {@code ClientOptions}.
*
* @return the copy
*/
ClientOptions copy();
static ClientOptions create() {
return new ClientOptionsImpl();
}
}