Skip to content

Commit 0a56ba0

Browse files
reformat
1 parent c3ed544 commit 0a56ba0

File tree

2 files changed

+66
-65
lines changed

2 files changed

+66
-65
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ The mapping from Http Json Response to SQL table schema is done via Flink's Json
675675
instead `HttpSinkRequestEntry`.
676676
- Version 0.20
677677
- Http source table parameters: `gid.connector.http.source.lookup.error.code` and `gid.connector.http.source.lookup.error.code.exclude` were removed. These parameters described http status codes which was silently ignored by source lookup table (logged only). it's not recommended to ignore all error response but it's still possible. To do this set all codes as success: `'gid.connector.http.source.lookup.success-codes' = '1XX,2XX,3XX,4XX,5XX'` and ignore body from the others responses than 200s: `'gid.connector.http.source.lookup.ignored-response-codes' = '1XX,3XX,4XX,5XX'`. You can still exclude some error codes marking it as transition errors - `gid.connector.http.source.lookup.retry-codes`. Retry-codes have to be excluded from both `success-codes` and `ignored-response-codes`.
678+
- Added dependency io.github.resilience4j:resilience4j-retry
678679

679680
## TODO
680681

src/main/java/com/getindata/connectors/http/internal/table/lookup/HttpLookupTableSourceFactory.java

+65-65
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public class HttpLookupTableSourceFactory implements DynamicTableSourceFactory {
3636

3737
private static DataTypes.Field columnToField(Column column) {
3838
return FIELD(
39-
column.getName(),
40-
// only a column in a schema should have a time attribute,
41-
// a field should not propagate the attribute because it might be used in a
42-
// completely different context
43-
removeTimeAttribute(column.getDataType()));
39+
column.getName(),
40+
// only a column in a schema should have a time attribute,
41+
// a field should not propagate the attribute because it might be used in a
42+
// completely different context
43+
removeTimeAttribute(column.getDataType()));
4444
}
4545

4646
public static DataType row(List<Field> fields) {
@@ -50,36 +50,36 @@ public static DataType row(List<Field> fields) {
5050
@Override
5151
public DynamicTableSource createDynamicTableSource(Context dynamicTableContext) {
5252
FactoryUtil.TableFactoryHelper helper =
53-
FactoryUtil.createTableFactoryHelper(this, dynamicTableContext);
53+
FactoryUtil.createTableFactoryHelper(this, dynamicTableContext);
5454

5555
ReadableConfig readable = helper.getOptions();
5656
helper.validateExcept(
57-
// properties coming from org.apache.flink.table.api.config.ExecutionConfigOptions
58-
"table.",
59-
HttpConnectorConfigConstants.GID_CONNECTOR_HTTP,
60-
LOOKUP_REQUEST_FORMAT.key()
57+
// properties coming from org.apache.flink.table.api.config.ExecutionConfigOptions
58+
"table.",
59+
HttpConnectorConfigConstants.GID_CONNECTOR_HTTP,
60+
LOOKUP_REQUEST_FORMAT.key()
6161
);
6262
validateHttpLookupSourceOptions(readable);
6363

6464
DecodingFormat<DeserializationSchema<RowData>> decodingFormat =
65-
helper.discoverDecodingFormat(
66-
DeserializationFormatFactory.class,
67-
FactoryUtil.FORMAT
68-
);
65+
helper.discoverDecodingFormat(
66+
DeserializationFormatFactory.class,
67+
FactoryUtil.FORMAT
68+
);
6969

7070
HttpLookupConfig lookupConfig = getHttpLookupOptions(dynamicTableContext, readable);
7171

7272
ResolvedSchema resolvedSchema = dynamicTableContext.getCatalogTable().getResolvedSchema();
7373

7474
DataType physicalRowDataType =
75-
toRowDataType(resolvedSchema.getColumns(), Column::isPhysical);
75+
toRowDataType(resolvedSchema.getColumns(), Column::isPhysical);
7676

7777
return new HttpLookupTableSource(
78-
physicalRowDataType,
79-
lookupConfig,
80-
decodingFormat,
81-
dynamicTableContext,
82-
getLookupCache(readable)
78+
physicalRowDataType,
79+
lookupConfig,
80+
decodingFormat,
81+
dynamicTableContext,
82+
getLookupCache(readable)
8383
);
8484
}
8585

@@ -89,7 +89,7 @@ protected void validateHttpLookupSourceOptions(ReadableConfig tableOptions)
8989
tableOptions.getOptional(SOURCE_LOOKUP_OIDC_AUTH_TOKEN_ENDPOINT_URL).ifPresent(url -> {
9090
if (tableOptions.getOptional(SOURCE_LOOKUP_OIDC_AUTH_TOKEN_REQUEST).isEmpty()) {
9191
throw new IllegalArgumentException("Config option " +
92-
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_REQUEST.key() + " is required, if " +
92+
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_REQUEST.key() + " is required, if " +
9393
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_ENDPOINT_URL.key() + " is configured.");
9494
}
9595
});
@@ -108,57 +108,57 @@ public Set<ConfigOption<?>> requiredOptions() {
108108
@Override
109109
public Set<ConfigOption<?>> optionalOptions() {
110110
return Set.of(
111-
URL_ARGS,
112-
ASYNC_POLLING,
113-
LOOKUP_METHOD,
114-
REQUEST_CALLBACK_IDENTIFIER,
115-
116-
LookupOptions.CACHE_TYPE,
117-
LookupOptions.PARTIAL_CACHE_EXPIRE_AFTER_ACCESS,
118-
LookupOptions.PARTIAL_CACHE_EXPIRE_AFTER_WRITE,
119-
LookupOptions.PARTIAL_CACHE_MAX_ROWS,
120-
LookupOptions.PARTIAL_CACHE_CACHE_MISSING_KEY,
121-
122-
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_EXPIRY_REDUCTION,
123-
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_REQUEST,
124-
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_ENDPOINT_URL,
125-
126-
LookupOptions.MAX_RETRIES,
127-
SOURCE_LOOKUP_RETRY_STRATEGY,
128-
SOURCE_LOOKUP_RETRY_FIXED_DELAY_DELAY,
129-
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_INITIAL_BACKOFF,
130-
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_MULTIPLIER,
131-
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_MAX_BACKOFF,
132-
133-
SOURCE_LOOKUP_HTTP_SUCCESS_CODES,
134-
SOURCE_LOOKUP_HTTP_RETRY_CODES,
135-
SOURCE_LOOKUP_HTTP_IGNORED_RESPONSE_CODES,
136-
137-
SOURCE_LOOKUP_CONNECTION_TIMEOUT // TODO: add request timeout from properties
111+
URL_ARGS,
112+
ASYNC_POLLING,
113+
LOOKUP_METHOD,
114+
REQUEST_CALLBACK_IDENTIFIER,
115+
116+
LookupOptions.CACHE_TYPE,
117+
LookupOptions.PARTIAL_CACHE_EXPIRE_AFTER_ACCESS,
118+
LookupOptions.PARTIAL_CACHE_EXPIRE_AFTER_WRITE,
119+
LookupOptions.PARTIAL_CACHE_MAX_ROWS,
120+
LookupOptions.PARTIAL_CACHE_CACHE_MISSING_KEY,
121+
122+
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_EXPIRY_REDUCTION,
123+
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_REQUEST,
124+
SOURCE_LOOKUP_OIDC_AUTH_TOKEN_ENDPOINT_URL,
125+
126+
LookupOptions.MAX_RETRIES,
127+
SOURCE_LOOKUP_RETRY_STRATEGY,
128+
SOURCE_LOOKUP_RETRY_FIXED_DELAY_DELAY,
129+
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_INITIAL_BACKOFF,
130+
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_MULTIPLIER,
131+
SOURCE_LOOKUP_RETRY_EXPONENTIAL_DELAY_MAX_BACKOFF,
132+
133+
SOURCE_LOOKUP_HTTP_SUCCESS_CODES,
134+
SOURCE_LOOKUP_HTTP_RETRY_CODES,
135+
SOURCE_LOOKUP_HTTP_IGNORED_RESPONSE_CODES,
136+
137+
SOURCE_LOOKUP_CONNECTION_TIMEOUT // TODO: add request timeout from properties
138138
);
139139
}
140140

141141
private HttpLookupConfig getHttpLookupOptions(Context context, ReadableConfig readableConfig) {
142142

143143
Properties httpConnectorProperties =
144-
ConfigUtils.getHttpConnectorProperties(context.getCatalogTable().getOptions());
144+
ConfigUtils.getHttpConnectorProperties(context.getCatalogTable().getOptions());
145145

146146
final HttpPostRequestCallbackFactory<HttpLookupSourceRequestEntry>
147147
postRequestCallbackFactory =
148-
FactoryUtil.discoverFactory(
148+
FactoryUtil.discoverFactory(
149149
context.getClassLoader(),
150150
HttpPostRequestCallbackFactory.class,
151151
readableConfig.get(REQUEST_CALLBACK_IDENTIFIER)
152-
);
152+
);
153153

154154
return HttpLookupConfig.builder()
155-
.lookupMethod(readableConfig.get(LOOKUP_METHOD))
156-
.url(readableConfig.get(URL))
157-
.useAsync(readableConfig.get(ASYNC_POLLING))
158-
.properties(httpConnectorProperties)
159-
.readableConfig(readableConfig)
160-
.httpPostRequestCallback(postRequestCallbackFactory.createHttpPostRequestCallback())
161-
.build();
155+
.lookupMethod(readableConfig.get(LOOKUP_METHOD))
156+
.url(readableConfig.get(URL))
157+
.useAsync(readableConfig.get(ASYNC_POLLING))
158+
.properties(httpConnectorProperties)
159+
.readableConfig(readableConfig)
160+
.httpPostRequestCallback(postRequestCallbackFactory.createHttpPostRequestCallback())
161+
.build();
162162
}
163163

164164
@Nullable
@@ -177,13 +177,13 @@ private LookupCache getLookupCache(ReadableConfig tableOptions) {
177177
// Backport from Flink 1.15-Master
178178
private DataType toRowDataType(List<Column> columns, Predicate<Column> columnPredicate) {
179179
return columns.stream()
180-
.filter(columnPredicate)
181-
.map(HttpLookupTableSourceFactory::columnToField)
182-
.collect(
183-
Collectors.collectingAndThen(Collectors.toList(),
184-
HttpLookupTableSourceFactory::row))
185-
// the row should never be null
186-
.notNull();
180+
.filter(columnPredicate)
181+
.map(HttpLookupTableSourceFactory::columnToField)
182+
.collect(
183+
Collectors.collectingAndThen(Collectors.toList(),
184+
HttpLookupTableSourceFactory::row))
185+
// the row should never be null
186+
.notNull();
187187
}
188188

189189
// Backport End

0 commit comments

Comments
 (0)