You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by gi...@apache.org on 2026/09/15 15:49:25 UTC
(seatunnel) 01/01: [Feature][Firebase] sink connector (#12232)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-12232-0b7fb5ddfaf430f361237e472eaac0291f725f87
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit 71a3c75183b2980780da023463d3a41c304213f7
Author: Kareem Ahmed <ka...@gmail.com>
AuthorDate: Tue Sep 15 15:48:58 2026 +0000
[Feature][Firebase] sink connector (#12232)
---
docs/en/connectors/sink/Firebase.md | 116 ++++++
docs/zh/connectors/sink/Firebase.md | 117 ++++++
plugin-mapping.properties | 1 +
seatunnel-connectors-v2/connector-firebase/pom.xml | 6 +
.../firebase/client/FirebaseHttpClient.java | 85 +++-
...SourceOptions.java => FirebaseBaseOptions.java} | 13 +-
.../firebase/config/FirebaseSinkOptions.java | 70 ++++
.../firebase/config/FirebaseSourceOptions.java | 35 +-
.../seatunnel/firebase/sink/FirebaseSink.java | 54 +++
.../firebase/sink/FirebaseSinkFactory.java | 60 +++
.../firebase/sink/FirebaseSinkWriter.java | 261 ++++++++++++
.../firebase/sink/FirebaseSinkWriterTest.java | 457 +++++++++++++++++++++
.../e2e/connector/firebase/FirebaseSinkIT.java | 196 +++++++++
.../test/resources/fake_source_to_firebase.conf | 62 +++
14 files changed, 1486 insertions(+), 47 deletions(-)
diff --git a/docs/en/connectors/sink/Firebase.md b/docs/en/connectors/sink/Firebase.md
new file mode 100644
index 0000000000..ec3615a1d9
--- /dev/null
+++ b/docs/en/connectors/sink/Firebase.md
@@ -0,0 +1,116 @@
+import ChangeLog from '../changelog/connector-firebase.md';
+
+# Firebase
+
+> Firebase Sink Connector
+
+## Description
+
+The Firebase Sink Connector allows writing batch and streaming data into Google Firebase Realtime Database via its REST API. It supports writing SeaTunnel internal rows into JSON node structures and handling CDC operations (`INSERT`, `UPDATE`, `DELETE`).
+
+## Key Features
+
+- [x] [batch](../../introduction/concepts/connector-v2-features.md)
+- [x] [cdc](../../introduction/concepts/connector-v2-features.md)
+- [ ] [exactly-once](../../introduction/concepts/connector-v2-features.md)
+
+---
+## Options
+
+| Name | Type | Required | Default | Description |
+|:-----------------------|:--------|:---------|:--------|:-----------------------------------------------------------------------------------------------------------|
+| `url` | String | Yes | - | The base URL of the Firebase Realtime Database (e.g., `https://<DATABASE_NAME>.firebaseio.com`). |
+| `path` | String | Yes | - | The JSON node path to write to (e.g., `users` or `logs/2026`). |
+| `service_account_path` | String | No | - | Path to the Google Service Account JSON key file. |
+| `credentials` | String | No | - | Base64-encoded Service Account JSON credentials. |
+| `database_secret` | String | No | - | Legacy Firebase database secret key or Web API token. |
+| `timeout_ms` | Integer | No | `10000` | HTTP connection and read timeout in milliseconds (must be > 0). |
+| `primary_keys` | List | No | - | Field names used to identify target node key. |
+| `key_prefix` | String | No | - | Fixed expression before key string. |
+| `key_postfix` | String | No | - | Fixed expression after key string. |
+| `key_delimiter` | String | No | `"_"` | Delimiter to concatenate values when using composite primary keys. |
+| `batch_size` | Integer | No | `100` | Number of records aggregated before issuing a multi-location update REST payload or batch write. |
+| `retry_max` | Integer | No | `3` | Maximum retry attempts for failed HTTP write operations. |
+| `ignore_null_values` | Boolean | No | `false` | If true, fields with null values are omitted from the JSON payload. |
+| `support_deletes` | Boolean | No | `true` | Whether to process `RowKind.DELETE` and `RowKind.UPDATE_BEFORE` records. |
+| `common-options` | Config | No | - | Sink common options. Refer to [Sink Common Options](../common-options/sink-common-options.md) for details. |
+
+---
+## Data Type Mapping
+
+The Firebase Sink connector converts SeaTunnel internal data types into JSON node structures:
+
+| SeaTunnel Data Type | Firebase / JSON Type |
+|:--------------------|:--------------------------|
+| `STRING` | `String` |
+| `INT` / `BIGINT` | `Number` (Integer) |
+| `FLOAT` / `DOUBLE` | `Number` (Floating point) |
+| `BOOLEAN` | `Boolean` |
+| `ROW` / `MAP` | `Object` (Nested node) |
+| `ARRAY` | `Array` |
+
+---
+## How to Set Up
+
+### 1. Authentication Options
+The connector supports three authentication methods:
+- **`service_account_path`**: Point to a local service account JSON key file downloaded from **Firebase Console > Project Settings > Service accounts**.
+- **`credentials`**: Provide the Base64-encoded content of a service account JSON file (useful for CI/CD or cloud secret injection).
+- **`database_secret`**: Pass a legacy database secret key or Web API token.
+
+### 2. Primary Key & Target Node Construction
+- **Primary Keys (`primary_keys`):** The connector uses the values from the specified primary key fields to construct the child node ID in Firebase.
+- **Composite Keys:** If multiple fields are provided in `primary_keys`, their values will be joined using `key_delimiter` (default: `_`).
+- **Formatting Node Keys (`key_prefix` / `key_postfix`):** Custom key prefixes and postfixes can be attached to generated keys (e.g., prefix `user_` with key `101` becomes node key `user_101`).
+
+---
+
+## Example
+
+### Writing to a Collection Node
+
+```hocon
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ FakeSource {
+ schema = {
+ fields {
+ id = "int"
+ name = "string"
+ role = "string"
+ }
+ }
+ rows = [
+ {
+ kind = INSERT
+ fields = [101, "Alice", "Admin"]
+ },
+ {
+ kind = INSERT
+ fields = [102, "Bob", "Developer"]
+ }
+ ]
+ plugin_output = "fake_users"
+ }
+}
+
+sink {
+ Firebase {
+ plugin_input = "fake_users"
+ url = "https://my-app-default-rtdb.firebaseio.com"
+ path = "users"
+ service_account_path = "/etc/seatunnel/firebase-credentials.json"
+ primary_keys = ["id"]
+ key_prefix = "user_"
+ batch_size = 50
+ timeout_ms = 5000
+ }
+}
+```
+## Changelog
+
+<ChangeLog />
diff --git a/docs/zh/connectors/sink/Firebase.md b/docs/zh/connectors/sink/Firebase.md
new file mode 100644
index 0000000000..a734e5505c
--- /dev/null
+++ b/docs/zh/connectors/sink/Firebase.md
@@ -0,0 +1,117 @@
+import ChangeLog from '../changelog/connector-firebase.md';
+
+# Firebase
+
+> Firebase Sink Connector
+
+## 描述
+
+Firebase Sink Connector 用于通过 REST API 将批处理和流数据写入 Google Firebase Realtime Database。它支持将 SeaTunnel 内部行数据转换为 JSON 节点结构,并处理 CDC 操作(`INSERT`、`UPDATE`、`DELETE`)。
+
+## 主要特性
+
+- [x] [batch](../../introduction/concepts/connector-v2-features.md)
+- [x] [cdc](../../introduction/concepts/connector-v2-features.md)
+- [ ] [exactly-once](../../introduction/concepts/connector-v2-features.md)
+
+---
+## 参数配置
+
+| 参数名称 | 类型 | 是否必填 | 默认值 | 描述 |
+|:-----------------------|:--------|:---|:--------|:---------------------------------------------------------------------------------|
+| `url` | String | 是 | - | Firebase Realtime Database 的基础 URL(例如:`https://<DATABASE_NAME>.firebaseio.com`)。 |
+| `path` | String | 是 | - | 要写入的 JSON 节点路径(例如:`users` 或 `logs/2026`)。 |
+| `service_account_path` | String | 否 | - | Google 服务账号 JSON 密钥文件的路径。 |
+| `credentials` | String | 否 | - | 经过 Base64 编码的服务账号 JSON 凭据内容。 |
+| `database_secret` | String | 否 | - | 传统的 Firebase 数据库密钥或 Web API 令牌。 |
+| `timeout_ms` | Integer | 否 | `10000` | HTTP 连接和读取超时时间(毫秒,必须大于 0)。 |
+| `primary_keys` | List | 否 | - | 用于标识目标节点 Key 的字段名称列表。 |
+| `key_prefix` | String | 否 | - | 拼接在 Key 字符串前的固定前缀表达式。 |
+| `key_postfix` | String | 否 | - | 拼接在 Key 字符串后的固定后缀表达式。 |
+| `key_delimiter` | String | 否 | `"_"` | 使用复合主键时连接各字段值的分隔符。 |
+| `batch_size` | Integer | 否 | `100` | 在发送多位置更新 REST 请求或批量写入之前聚合的记录数。 |
+| `retry_max` | Integer | 否 | `3` | HTTP 写入操作失败时的最大重试次数。 |
+| `ignore_null_values` | Boolean | 否 | `false` | 如果设置为 true,JSON 载荷中将忽略值为 null 的字段。 |
+| `support_deletes` | Boolean | 否 | `true` | 是否处理 `RowKind.DELETE` 和 `RowKind.UPDATE_BEFORE` 记录。 |
+| `common-options` | Config | 否 | - | Sink 通用参数。详情请参考 [Sink Common Options](../common-options/sink-common-options.md)。 |
+
+---
+## 数据类型映射
+
+Firebase Sink Connector 将 SeaTunnel 内部数据类型转换为 JSON 节点结构:
+
+| SeaTunnel 数据类型 | Firebase / JSON 数据类型 |
+|:-------------------|:--------------------------|
+| `STRING` | `String` |
+| `INT` / `BIGINT` | `Number` (Integer) |
+| `FLOAT` / `DOUBLE` | `Number` (Floating point) |
+| `BOOLEAN` | `Boolean` |
+| `ROW` / `MAP` | `Object` (Nested node) |
+| `ARRAY` | `Array` |
+
+---
+## 配置指南
+
+### 1. 身份验证选项
+Connector 支持三种身份验证方式:
+- **`service_account_path`**:指向从 **Firebase 控制台 > 项目设置 > 服务账号** 下载的本地服务账号 JSON 密钥文件。
+- **`credentials`**:提供 Base64 编码后的服务账号 JSON 内容(适用于 CI/CD 或云端凭据注入)。
+- **`database_secret`**:传递传统的数据库密钥或 Web API 令牌。
+
+### 2. 主键与目标节点构建
+- **主键 (`primary_keys`)**:Connector 使用指定主键字段的值来构建 Firebase 中的子节点 ID。
+- **复合主键**:如果在 `primary_keys` 中指定了多个字段,其值将使用 `key_delimiter`(默认值:`_`)进行连接。
+- **格式化节点 Key (`key_prefix` / `key_postfix`)**:可以为生成的 Key 附加自定义的前缀和后缀(例如:前缀为 `user_`,Key 为 `101`,生成的节点 Key 为 `user_101`)。
+
+---
+
+## 示例
+
+### 写入集合节点 (Collection Node)
+
+```hocon
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ FakeSource {
+ schema = {
+ fields {
+ id = "int"
+ name = "string"
+ role = "string"
+ }
+ }
+ rows = [
+ {
+ kind = INSERT
+ fields = [101, "Alice", "Admin"]
+ },
+ {
+ kind = INSERT
+ fields = [102, "Bob", "Developer"]
+ }
+ ]
+ plugin_output = "fake_users"
+ }
+}
+
+sink {
+ Firebase {
+ plugin_input = "fake_users"
+ url = "https://my-app-default-rtdb.firebaseio.com"
+ path = "users"
+ service_account_path = "/etc/seatunnel/firebase-credentials.json"
+ primary_keys = ["id"]
+ key_prefix = "user_"
+ batch_size = 50
+ timeout_ms = 5000
+ }
+}
+```
+
+## 变更日志
+
+<ChangeLog />
\ No newline at end of file
diff --git a/plugin-mapping.properties b/plugin-mapping.properties
index 265a2c5398..641900fbe1 100644
--- a/plugin-mapping.properties
+++ b/plugin-mapping.properties
@@ -54,6 +54,7 @@ seatunnel.sink.OssJindoFile = connector-file-jindo-oss
seatunnel.source.CosFile = connector-file-cos
seatunnel.sink.CosFile = connector-file-cos
seatunnel.source.Firebase = connector-firebase
+seatunnel.sink.Firebase = connector-firebase
seatunnel.source.Pulsar = connector-pulsar
seatunnel.sink.DingTalk = connector-dingtalk
seatunnel.source.Elasticsearch = connector-elasticsearch
diff --git a/seatunnel-connectors-v2/connector-firebase/pom.xml b/seatunnel-connectors-v2/connector-firebase/pom.xml
index 523c4d1b5d..b417b21ce6 100644
--- a/seatunnel-connectors-v2/connector-firebase/pom.xml
+++ b/seatunnel-connectors-v2/connector-firebase/pom.xml
@@ -40,6 +40,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>connector-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java
index 2c55c97120..1c1316d571 100644
--- a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/client/FirebaseHttpClient.java
@@ -35,6 +35,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URI;
@@ -132,7 +133,17 @@ public class FirebaseHttpClient {
/** Constructs a full REST URL with .json extension and query string parameters. */
String buildUrl(String subPath, String extraQueryParam, boolean includeExtraParams) {
- StringBuilder urlBuilder = new StringBuilder(baseUrl);
+ String base = baseUrl;
+ String baseQuery = "";
+ int queryIdx = base.indexOf('?');
+ if (queryIdx != -1) {
+ baseQuery = base.substring(queryIdx + 1);
+ base = base.substring(0, queryIdx);
+ }
+
+ base = base.replaceAll("/+$", "");
+
+ StringBuilder urlBuilder = new StringBuilder(base);
String cleanSubPath = subPath == null ? "" : subPath.replaceAll("^/+|/+$", "");
urlBuilder.append("/").append(cleanSubPath);
@@ -143,6 +154,10 @@ public class FirebaseHttpClient {
queryParts.add(extraQueryParam);
}
+ if (!baseQuery.isEmpty()) {
+ queryParts.add(baseQuery);
+ }
+
if (databaseSecret != null && !databaseSecret.isEmpty()) {
queryParts.add("auth=" + encodeUriComponent(databaseSecret));
}
@@ -224,6 +239,74 @@ public class FirebaseHttpClient {
}
}
+ /**
+ * Executes a PATCH request with a JSON payload for multi-location updates or record merges.
+ * Endpoint: PATCH /<path>.json
+ *
+ * @param subPath Target path relative to root (or empty string for root update)
+ * @param jsonPayload JSON body representing path-to-value or field updates
+ */
+ public void executePatch(String subPath, String jsonPayload) {
+ String endpointUrl = buildUrl(subPath, null, false);
+ executeWrite("PATCH", endpointUrl, jsonPayload);
+ }
+
+ private void executeWrite(String method, String urlStr, String jsonPayload) {
+ HttpURLConnection connection = null;
+ try {
+ URL url;
+ try {
+ url = URI.create(urlStr).toURL();
+ } catch (IllegalArgumentException e) {
+ throw new SeaTunnelException(
+ "Invalid Firebase REST URI constructed. Check parameter formatting.", e);
+ }
+ connection = (HttpURLConnection) url.openConnection();
+
+ if ("PATCH".equalsIgnoreCase(method)) {
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("X-HTTP-Method-Override", "PATCH");
+ } else {
+ connection.setRequestMethod(method);
+ }
+
+ connection.setConnectTimeout(timeoutMs);
+ connection.setReadTimeout(timeoutMs);
+ connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
+ connection.setRequestProperty("Accept", "application/json");
+ connection.setDoOutput(true);
+ connection.setInstanceFollowRedirects(true);
+
+ if (credentials != null) {
+ String token = getAccessToken();
+ connection.setRequestProperty("Authorization", "Bearer " + token);
+ }
+
+ try (OutputStream os = connection.getOutputStream()) {
+ byte[] input = jsonPayload.getBytes(StandardCharsets.UTF_8);
+ os.write(input, 0, input.length);
+ }
+
+ int responseCode = connection.getResponseCode();
+ if (responseCode < 200 || responseCode >= 300) {
+ String rawErrorBody = readErrorStream(connection);
+ throw new SeaTunnelException(
+ String.format(
+ "Firebase HTTP %s request failed with status code %d. Response body: %s",
+ method,
+ responseCode,
+ rawErrorBody.isEmpty() ? "N/A" : rawErrorBody));
+ }
+ } catch (IOException e) {
+ throw new SeaTunnelException(
+ "Failed to execute HTTP " + method + " request to Firebase", e);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
private String encodeUriComponent(String value) {
try {
return URLEncoder.encode(value, StandardCharsets.UTF_8.name())
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseBaseOptions.java
similarity index 84%
copy from seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java
copy to seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseBaseOptions.java
index 7da9643fdb..1fc5d2c124 100644
--- a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseBaseOptions.java
@@ -19,11 +19,8 @@ package org.apache.seatunnel.connectors.seatunnel.firebase.config;
import org.apache.seatunnel.api.configuration.Option;
import org.apache.seatunnel.api.configuration.Options;
-import org.apache.seatunnel.api.options.ConnectorCommonOptions;
-import java.util.Map;
-
-public class FirebaseSourceOptions {
+public class FirebaseBaseOptions {
public static final Option<String> URL =
Options.key("url")
.stringType()
@@ -34,7 +31,6 @@ public class FirebaseSourceOptions {
.stringType()
.noDefaultValue()
.withDescription("The JSON node path to read from.");
- public static final Option<Map<String, Object>> SCHEMA = ConnectorCommonOptions.SCHEMA;
public static final Option<String> SERVICE_ACCOUNT_PATH =
Options.key("service_account_path")
.stringType()
@@ -50,17 +46,10 @@ public class FirebaseSourceOptions {
.stringType()
.noDefaultValue()
.withDescription("Legacy Firebase database secret key or Web API token.");
-
public static final Option<Integer> TIMEOUT_MS =
Options.key("timeout_ms")
.intType()
.defaultValue(10000)
.withDescription(
"HTTP connection and read timeout in milliseconds (must be > 0).");
-
- public static final Option<Map<String, String>> QUERY_PARAMS =
- Options.key("query_params")
- .mapType()
- .noDefaultValue()
- .withDescription("Additional REST API query parameters.");
}
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSinkOptions.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSinkOptions.java
new file mode 100644
index 0000000000..0d648ec46e
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSinkOptions.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.firebase.config;
+
+import org.apache.seatunnel.api.configuration.Option;
+import org.apache.seatunnel.api.configuration.Options;
+
+import java.util.List;
+
+public class FirebaseSinkOptions extends FirebaseBaseOptions {
+ public static final Option<List<String>> PRIMARY_KEYS =
+ Options.key("primary_keys")
+ .listType(String.class)
+ .noDefaultValue()
+ .withDescription("Field names used to identify target node.");
+ public static final Option<String> KEY_PREFIX =
+ Options.key("key_prefix")
+ .stringType()
+ .noDefaultValue()
+ .withDescription("Fixed expression before key string.");
+ public static final Option<String> KEY_POSTFIX =
+ Options.key("key_postfix")
+ .stringType()
+ .noDefaultValue()
+ .withDescription("Fixed expression after key string.");
+ public static final Option<String> KEY_DELIMITER =
+ Options.key("key_delimiter")
+ .stringType()
+ .defaultValue("_")
+ .withDescription(
+ "Delimiter to concatenate values when using composite primary keys.");
+ public static final Option<Integer> BATCH_SIZE =
+ Options.key("batch_size")
+ .intType()
+ .defaultValue(100)
+ .withDescription(
+ "Number of records aggregated before issuing a multi-location update REST payload or batch write.");
+ public static final Option<Integer> RETRY_MAX =
+ Options.key("retry_max")
+ .intType()
+ .defaultValue(3)
+ .withDescription("Maximum retry attempts for failed HTTP write operations.");
+ public static final Option<Boolean> IGNORE_NULL_VALUES =
+ Options.key("ignore_null_values")
+ .booleanType()
+ .defaultValue(false)
+ .withDescription(
+ "If true, fields with null values are omitted from the JSON payload.");
+ public static final Option<Boolean> SUPPORT_DELETES =
+ Options.key("support_deletes")
+ .booleanType()
+ .defaultValue(true)
+ .withDescription(
+ "Whether to process RowKind.DELETE and RowKind.UPDATE_BEFORE records.");
+}
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java
index 7da9643fdb..7104f27101 100644
--- a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/config/FirebaseSourceOptions.java
@@ -23,41 +23,8 @@ import org.apache.seatunnel.api.options.ConnectorCommonOptions;
import java.util.Map;
-public class FirebaseSourceOptions {
- public static final Option<String> URL =
- Options.key("url")
- .stringType()
- .noDefaultValue()
- .withDescription("The base URL of the Firebase Realtime Database.");
- public static final Option<String> PATH =
- Options.key("path")
- .stringType()
- .noDefaultValue()
- .withDescription("The JSON node path to read from.");
+public class FirebaseSourceOptions extends FirebaseBaseOptions {
public static final Option<Map<String, Object>> SCHEMA = ConnectorCommonOptions.SCHEMA;
- public static final Option<String> SERVICE_ACCOUNT_PATH =
- Options.key("service_account_path")
- .stringType()
- .noDefaultValue()
- .withDescription("Path to the Google Service Account JSON key file.");
- public static final Option<String> CREDENTIALS =
- Options.key("credentials")
- .stringType()
- .noDefaultValue()
- .withDescription("Base64-encoded Service Account JSON credentials.");
- public static final Option<String> DATABASE_SECRET =
- Options.key("database_secret")
- .stringType()
- .noDefaultValue()
- .withDescription("Legacy Firebase database secret key or Web API token.");
-
- public static final Option<Integer> TIMEOUT_MS =
- Options.key("timeout_ms")
- .intType()
- .defaultValue(10000)
- .withDescription(
- "HTTP connection and read timeout in milliseconds (must be > 0).");
-
public static final Option<Map<String, String>> QUERY_PARAMS =
Options.key("query_params")
.mapType()
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSink.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSink.java
new file mode 100644
index 0000000000..2d075224b1
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSink.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.firebase.sink;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSimpleSink;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+
+import java.io.IOException;
+import java.util.Optional;
+
+public class FirebaseSink extends AbstractSimpleSink<SeaTunnelRow, Void> {
+ private final ReadonlyConfig config;
+ private final CatalogTable catalogTable;
+
+ public FirebaseSink(ReadonlyConfig config, CatalogTable catalogTable) {
+ this.config = config;
+ this.catalogTable = catalogTable;
+ }
+
+ @Override
+ public String getPluginName() {
+ return "Firebase";
+ }
+
+ @Override
+ public Optional<CatalogTable> getWriteCatalogTable() {
+ return Optional.ofNullable(catalogTable);
+ }
+
+ @Override
+ public AbstractSinkWriter<SeaTunnelRow, Void> createWriter(SinkWriter.Context context)
+ throws IOException {
+ return new FirebaseSinkWriter(catalogTable, config);
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkFactory.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkFactory.java
new file mode 100644
index 0000000000..0f1a28ab02
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkFactory.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.firebase.sink;
+
+import org.apache.seatunnel.api.configuration.util.OptionRule;
+import org.apache.seatunnel.api.table.connector.TableSink;
+import org.apache.seatunnel.api.table.factory.Factory;
+import org.apache.seatunnel.api.table.factory.TableSinkFactory;
+import org.apache.seatunnel.api.table.factory.TableSinkFactoryContext;
+import org.apache.seatunnel.connectors.seatunnel.firebase.config.FirebaseSinkOptions;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(Factory.class)
+public class FirebaseSinkFactory implements TableSinkFactory {
+ @Override
+ public String factoryIdentifier() {
+ return "Firebase";
+ }
+
+ @Override
+ public OptionRule optionRule() {
+ return OptionRule.builder()
+ .required(FirebaseSinkOptions.URL, FirebaseSinkOptions.PATH)
+ .optional(
+ FirebaseSinkOptions.SERVICE_ACCOUNT_PATH,
+ FirebaseSinkOptions.CREDENTIALS,
+ FirebaseSinkOptions.DATABASE_SECRET,
+ FirebaseSinkOptions.TIMEOUT_MS,
+ FirebaseSinkOptions.PRIMARY_KEYS,
+ FirebaseSinkOptions.KEY_PREFIX,
+ FirebaseSinkOptions.KEY_POSTFIX,
+ FirebaseSinkOptions.KEY_DELIMITER,
+ FirebaseSinkOptions.BATCH_SIZE,
+ FirebaseSinkOptions.IGNORE_NULL_VALUES,
+ FirebaseSinkOptions.RETRY_MAX,
+ FirebaseSinkOptions.SUPPORT_DELETES)
+ .build();
+ }
+
+ @Override
+ public TableSink createSink(TableSinkFactoryContext context) {
+ return () -> new FirebaseSink(context.getOptions(), context.getCatalogTable());
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriter.java b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriter.java
new file mode 100644
index 0000000000..db519416bc
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-firebase/src/main/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriter.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.firebase.sink;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.type.RowKind;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.SeaTunnelException;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.firebase.client.FirebaseHttpClient;
+import org.apache.seatunnel.connectors.seatunnel.firebase.config.FirebaseSinkOptions;
+
+import org.apache.commons.collections4.CollectionUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+
+@Slf4j
+public class FirebaseSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private final FirebaseHttpClient httpClient;
+ private final SeaTunnelRowType rowType;
+ private final String basePath;
+ private final List<String> primaryKeys;
+ private final String keyPrefix;
+ private final String keyPostfix;
+ private final String keyDelimiter;
+ private final int batchSize;
+ private final int retryMax;
+ private final boolean ignoreNullValues;
+ private final boolean supportDeletes;
+
+ private final Map<String, Object> bufferMap;
+
+ public FirebaseSinkWriter(CatalogTable catalogTable, ReadonlyConfig config) {
+ this.httpClient = new FirebaseHttpClient(config);
+ this.rowType = catalogTable.getSeaTunnelRowType();
+ this.basePath = config.get(FirebaseSinkOptions.PATH).replaceAll("^/+|/+$", "");
+
+ List<String> pkList = config.getOptional(FirebaseSinkOptions.PRIMARY_KEYS).orElse(null);
+ if (CollectionUtils.isEmpty(pkList)
+ && catalogTable.getTableSchema() != null
+ && catalogTable.getTableSchema().getPrimaryKey() != null) {
+ pkList = catalogTable.getTableSchema().getPrimaryKey().getColumnNames();
+ }
+ this.primaryKeys = pkList;
+
+ this.keyPrefix = config.getOptional(FirebaseSinkOptions.KEY_PREFIX).orElse("");
+ this.keyPostfix = config.getOptional(FirebaseSinkOptions.KEY_POSTFIX).orElse("");
+ this.keyDelimiter = config.get(FirebaseSinkOptions.KEY_DELIMITER);
+ this.batchSize = config.get(FirebaseSinkOptions.BATCH_SIZE);
+ this.retryMax = config.get(FirebaseSinkOptions.RETRY_MAX);
+ this.ignoreNullValues = config.get(FirebaseSinkOptions.IGNORE_NULL_VALUES);
+ this.supportDeletes = config.get(FirebaseSinkOptions.SUPPORT_DELETES);
+
+ validatePrimaryKeysWithSupportDeletes(config, catalogTable);
+
+ this.bufferMap = new LinkedHashMap<>();
+ }
+
+ public FirebaseSinkWriter(
+ FirebaseHttpClient client, CatalogTable catalogTable, ReadonlyConfig config) {
+ this.httpClient = client;
+ this.rowType = catalogTable.getSeaTunnelRowType();
+ this.basePath = config.get(FirebaseSinkOptions.PATH).replaceAll("^/+|/+$", "");
+
+ List<String> pkList = config.getOptional(FirebaseSinkOptions.PRIMARY_KEYS).orElse(null);
+ if (CollectionUtils.isEmpty(pkList)
+ && catalogTable.getTableSchema() != null
+ && catalogTable.getTableSchema().getPrimaryKey() != null) {
+ pkList = catalogTable.getTableSchema().getPrimaryKey().getColumnNames();
+ }
+ this.primaryKeys = pkList;
+
+ this.keyPrefix = config.getOptional(FirebaseSinkOptions.KEY_PREFIX).orElse("");
+ this.keyPostfix = config.getOptional(FirebaseSinkOptions.KEY_POSTFIX).orElse("");
+ this.keyDelimiter = config.get(FirebaseSinkOptions.KEY_DELIMITER);
+ this.batchSize = config.get(FirebaseSinkOptions.BATCH_SIZE);
+ this.retryMax = config.get(FirebaseSinkOptions.RETRY_MAX);
+ this.ignoreNullValues = config.get(FirebaseSinkOptions.IGNORE_NULL_VALUES);
+ this.supportDeletes = config.get(FirebaseSinkOptions.SUPPORT_DELETES);
+
+ validatePrimaryKeysWithSupportDeletes(config, catalogTable);
+
+ this.bufferMap = new LinkedHashMap<>();
+ }
+
+ private void validatePrimaryKeysWithSupportDeletes(
+ ReadonlyConfig config, CatalogTable catalogTable) {
+ if (config.get(FirebaseSinkOptions.SUPPORT_DELETES)) {
+ List<String> primaryKeys = config.get(FirebaseSinkOptions.PRIMARY_KEYS);
+ boolean hasCatalogPrimaryKey =
+ catalogTable.getTableSchema() != null
+ && catalogTable.getTableSchema().getPrimaryKey() != null
+ && !catalogTable
+ .getTableSchema()
+ .getPrimaryKey()
+ .getColumnNames()
+ .isEmpty();
+
+ if ((primaryKeys == null || primaryKeys.isEmpty()) && !hasCatalogPrimaryKey) {
+ throw new SeaTunnelException(
+ "primary_keys must be configured when support_deletes is enabled, if no primary_keys set support_deletes=false.");
+ }
+ }
+ }
+
+ @Override
+ public void write(SeaTunnelRow element) throws IOException {
+ RowKind rowKind = element.getRowKind();
+ if (!supportDeletes && (rowKind == RowKind.DELETE || rowKind == RowKind.UPDATE_BEFORE)) {
+ log.debug("Skipping row with RowKind {} because support_deletes is disabled", rowKind);
+ return;
+ }
+ String nodeKey = resolveNodeKey(element);
+ String relativePath = basePath.isEmpty() ? nodeKey : basePath + "/" + nodeKey;
+ if (rowKind == RowKind.DELETE || rowKind == RowKind.UPDATE_BEFORE) {
+ bufferMap.put(relativePath, null);
+ } else {
+ Map<String, Object> rowDataMap = serializeRowToMap(element);
+ bufferMap.put(relativePath, rowDataMap);
+ }
+
+ if (bufferMap.size() >= batchSize) {
+ flush();
+ }
+ }
+
+ private String resolveNodeKey(SeaTunnelRow row) {
+ String keyBody;
+
+ if (CollectionUtils.isEmpty(primaryKeys)) {
+ keyBody = UUID.randomUUID().toString();
+ } else {
+ List<String> values = new ArrayList<>();
+ for (String pkName : primaryKeys) {
+ int fieldIndex = rowType.indexOf(pkName);
+ if (fieldIndex < 0) {
+ throw new SeaTunnelException(
+ String.format(
+ "Primary key field '%s' not found in row schema", pkName));
+ }
+ Object fieldValue = row.getField(fieldIndex);
+ if (fieldValue == null) {
+ throw new SeaTunnelException(
+ String.format("Primary key field '%s' cannot be null", pkName));
+ }
+ values.add(fieldValue.toString());
+ }
+ keyBody = String.join(keyDelimiter, values);
+ }
+
+ return keyPrefix + keyBody + keyPostfix;
+ }
+
+ private Map<String, Object> serializeRowToMap(SeaTunnelRow row) {
+ Map<String, Object> map = new LinkedHashMap<>();
+ String[] fieldNames = rowType.getFieldNames();
+ for (int i = 0; i < fieldNames.length; i++) {
+ Object value = row.getField(i);
+ if (value == null && ignoreNullValues) {
+ continue;
+ }
+ map.put(fieldNames[i], value);
+ }
+ return map;
+ }
+
+ private void flush() throws IOException {
+ if (bufferMap.isEmpty()) {
+ return;
+ }
+
+ String jsonPayload;
+ try {
+ jsonPayload = OBJECT_MAPPER.writeValueAsString(bufferMap);
+ } catch (Exception e) {
+ throw new SeaTunnelException(
+ "Failed to serialize Firebase multi-location batch payload", e);
+ }
+ executeWithRetry(jsonPayload);
+ bufferMap.clear();
+ }
+
+ private void executeWithRetry(String jsonPayload) {
+ int attempt = 0;
+ long backoffMs = 1000L;
+
+ while (attempt <= retryMax) {
+ try {
+ attempt++;
+ httpClient.executePatch("", jsonPayload);
+ return;
+ } catch (Exception e) {
+ if (attempt > retryMax) {
+ throw new SeaTunnelException(
+ String.format(
+ "Failed to write batch payload to Firebase after %d attempts",
+ retryMax),
+ e);
+ }
+ log.warn(
+ "Attempt {}/{} failed to write batch to Firebase: {}. Retrying in {} ms...",
+ attempt,
+ retryMax,
+ e.getMessage(),
+ backoffMs);
+ try {
+ Thread.sleep(backoffMs);
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ throw new SeaTunnelException(
+ "Interrupted while waiting to retry Firebase batch write", ie);
+ }
+ backoffMs *= 2;
+ }
+ }
+ }
+
+ @Override
+ public Optional<Void> prepareCommit() {
+ try {
+ flush();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public void close() throws IOException {
+ flush();
+ }
+}
diff --git a/seatunnel-connectors-v2/connector-firebase/src/test/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriterTest.java b/seatunnel-connectors-v2/connector-firebase/src/test/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriterTest.java
new file mode 100644
index 0000000000..819c916cad
--- /dev/null
+++ b/seatunnel-connectors-v2/connector-firebase/src/test/java/org/apache/seatunnel/connectors/seatunnel/firebase/sink/FirebaseSinkWriterTest.java
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.firebase.sink;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.catalog.PrimaryKey;
+import org.apache.seatunnel.api.table.catalog.TableIdentifier;
+import org.apache.seatunnel.api.table.catalog.TableSchema;
+import org.apache.seatunnel.api.table.type.BasicType;
+import org.apache.seatunnel.api.table.type.RowKind;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.SeaTunnelException;
+import org.apache.seatunnel.connectors.seatunnel.firebase.client.FirebaseHttpClient;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+@ExtendWith(MockitoExtension.class)
+class FirebaseSinkWriterTest {
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ @Mock private FirebaseHttpClient mockHttpClient;
+
+ @Captor private ArgumentCaptor<String> payloadCaptor;
+
+ private SeaTunnelRowType defaultRowType;
+ private CatalogTable defaultCatalogTable;
+
+ @BeforeEach
+ void setUp() {
+ defaultRowType =
+ new SeaTunnelRowType(
+ new String[] {"id", "dept_id", "name", "age"},
+ new SeaTunnelDataType<?>[] {
+ BasicType.INT_TYPE,
+ BasicType.STRING_TYPE,
+ BasicType.STRING_TYPE,
+ BasicType.INT_TYPE
+ });
+
+ TableSchema schema =
+ TableSchema.builder()
+ .column(PhysicalColumn.of("id", BasicType.INT_TYPE, 0, false, null, "id"))
+ .column(
+ PhysicalColumn.of(
+ "dept_id",
+ BasicType.STRING_TYPE,
+ 0,
+ false,
+ null,
+ "dept_id"))
+ .column(
+ PhysicalColumn.of(
+ "name", BasicType.STRING_TYPE, 0, true, null, "name"))
+ .column(PhysicalColumn.of("age", BasicType.INT_TYPE, 0, true, null, "age"))
+ .build();
+
+ defaultCatalogTable =
+ CatalogTable.of(
+ TableIdentifier.of("default", "default", "users"),
+ schema,
+ new HashMap<>(),
+ Collections.emptyList(),
+ "");
+ }
+
+ private ReadonlyConfig createConfig(Map<String, Object> map) {
+ Map<String, Object> baseMap = new HashMap<>();
+ baseMap.put("url", "https://test-db.firebaseio.com");
+ baseMap.put("path", "users");
+ baseMap.put("batch_size", 2);
+ baseMap.put("retry_max", 2);
+ baseMap.putAll(map);
+ return ReadonlyConfig.fromMap(baseMap);
+ }
+
+ @Nested
+ @DisplayName("1. Path and Key Resolution Tests")
+ class KeyResolutionTests {
+ @Test
+ @DisplayName("Single Primary Key Resolution")
+ void testSinglePrimaryKeyResolution() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 1); // Immediate flush
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {101, "eng", "John", 25});
+ writer.write(row);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("users/101"));
+ }
+
+ @Test
+ @DisplayName("Multi-Column Composite Primary Key Resolution with Delimiter")
+ void testCompositePrimaryKeyResolution() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Arrays.asList("dept_id", "id"));
+ map.put("key_delimiter", "#");
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {101, "eng", "John", 25});
+ writer.write(row);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("users/eng#101"));
+ }
+
+ @Test
+ @DisplayName("Prefix and Postfix Customization")
+ void testPrefixAndPostfixKeyResolution() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("key_prefix", "usr_");
+ map.put("key_postfix", "_node");
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {50, "hr", "Alice", 30});
+ writer.write(row);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("users/usr_50_node"));
+ }
+
+ @Test
+ @DisplayName("Primary Key fallback to CatalogTable PrimaryKey Schema")
+ void testFallbackToCatalogTablePrimaryKey() throws IOException {
+ TableSchema schemaWithPk =
+ TableSchema.builder()
+ .column(
+ PhysicalColumn.of(
+ "id", BasicType.INT_TYPE, 0, false, null, "id"))
+ .column(
+ PhysicalColumn.of(
+ "name", BasicType.STRING_TYPE, 0, true, null, "name"))
+ .primaryKey(
+ PrimaryKey.of(
+ "pk_users",
+ Collections.singletonList(
+ "id"))) // <--- Use primaryKey() directly
+ .build();
+
+ CatalogTable catalogTableWithPk =
+ CatalogTable.of(
+ TableIdentifier.of("default", "default", "users"),
+ schemaWithPk,
+ new HashMap<>(),
+ Collections.emptyList(),
+ "");
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, catalogTableWithPk, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {99, "FallbackUser"});
+ writer.write(row);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("users/99"));
+ }
+
+ @Test
+ @DisplayName("Root path configuration (path is empty string)")
+ void testRootPathConfiguration() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("path", "");
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {7, "eng", "Bob", 40});
+ writer.write(row);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("7"));
+ }
+ }
+
+ @Nested
+ @DisplayName("2. Row Operations & Serialization Tests")
+ class OperationsAndSerializationTests {
+ @Test
+ @DisplayName("CDC DELETE row maps to null payload in multi-location PATCH")
+ void testDeleteRowMapping() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("support_deletes", true);
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow deleteRow = new SeaTunnelRow(new Object[] {101, "eng", "Kareem", 25});
+ deleteRow.setRowKind(RowKind.DELETE);
+
+ writer.write(deleteRow);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertTrue(payload.containsKey("users/101"));
+ assertNull(payload.get("users/101"));
+ }
+
+ @Test
+ @DisplayName("Ignore DELETE records when support_deletes is false")
+ void testDisabledDeleteSupport() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("support_deletes", false);
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow deleteRow = new SeaTunnelRow(new Object[] {101, "eng", "John", 25});
+ deleteRow.setRowKind(RowKind.DELETE);
+
+ writer.write(deleteRow);
+ writer.close();
+
+ verify(mockHttpClient, never()).executePatch(anyString(), anyString());
+ }
+
+ @Test
+ @DisplayName("ignore_null_values=true excludes null fields from row payload")
+ void testIgnoreNullValuesTrue() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("ignore_null_values", true);
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow rowWithNulls = new SeaTunnelRow(new Object[] {200, "eng", null, 28});
+ writer.write(rowWithNulls);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> rowMap = (Map<String, Object>) payload.get("users/200");
+
+ assertEquals(200, rowMap.get("id"));
+ assertEquals("eng", rowMap.get("dept_id"));
+ assertEquals(28, rowMap.get("age"));
+ assertFalse(rowMap.containsKey("name"));
+ }
+
+ @Test
+ @DisplayName("ignore_null_values=false retains null fields in payload")
+ void testIgnoreNullValuesFalse() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("ignore_null_values", false);
+ map.put("batch_size", 1);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow rowWithNulls = new SeaTunnelRow(new Object[] {200, "eng", null, 28});
+ writer.write(rowWithNulls);
+
+ verify(mockHttpClient).executePatch(eq(""), payloadCaptor.capture());
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> rowMap = (Map<String, Object>) payload.get("users/200");
+
+ assertTrue(rowMap.containsKey("name"));
+ assertNull(rowMap.get("name"));
+ }
+ }
+
+ @Nested
+ @DisplayName("3. Batch Buffering & Retry Logic Tests")
+ class BatchingAndRetryTests {
+ @Test
+ @DisplayName("Buffer flushes automatically when batch_size is reached")
+ void testBatchSizeFlushTrigger() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 2);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row1 = new SeaTunnelRow(new Object[] {1, "hr", "User1", 20});
+ SeaTunnelRow row2 = new SeaTunnelRow(new Object[] {2, "hr", "User2", 22});
+
+ writer.write(row1);
+ verify(mockHttpClient, never()).executePatch(anyString(), anyString());
+
+ writer.write(row2);
+ verify(mockHttpClient, times(1)).executePatch(eq(""), payloadCaptor.capture());
+
+ Map<String, Object> payload =
+ OBJECT_MAPPER.readValue(
+ payloadCaptor.getValue(), new TypeReference<Map<String, Object>>() {});
+
+ assertEquals(2, payload.size());
+ assertTrue(payload.containsKey("users/1"));
+ assertTrue(payload.containsKey("users/2"));
+ }
+
+ @Test
+ @DisplayName("close() flushes remaining uncommitted buffered records")
+ void testCloseFlushesBuffer() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 5);
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {10, "fin", "User10", 35});
+ writer.write(row);
+
+ verify(mockHttpClient, never()).executePatch(anyString(), anyString());
+
+ writer.close();
+ verify(mockHttpClient, times(1)).executePatch(eq(""), payloadCaptor.capture());
+ }
+
+ @Test
+ @DisplayName("Retry logic retries upon transient network failure and succeeds")
+ void testRetryLogicSuccess() throws IOException {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 1);
+ map.put("retry_max", 3);
+
+ doThrow(new SeaTunnelException("Transient connection timeout"))
+ .doNothing()
+ .when(mockHttpClient)
+ .executePatch(anyString(), anyString());
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {1, "eng", "RetryUser", 25});
+ writer.write(row);
+
+ verify(mockHttpClient, times(2)).executePatch(eq(""), anyString());
+ }
+
+ @Test
+ @DisplayName("Exhausting retry_max throws SeaTunnelException")
+ void testExhaustRetriesThrowsException() {
+ Map<String, Object> map = new HashMap<>();
+ map.put("primary_keys", Collections.singletonList("id"));
+ map.put("batch_size", 1);
+ map.put("retry_max", 2);
+
+ doThrow(new SeaTunnelException("Persistent 503 Server Error"))
+ .when(mockHttpClient)
+ .executePatch(anyString(), anyString());
+
+ FirebaseSinkWriter writer =
+ new FirebaseSinkWriter(mockHttpClient, defaultCatalogTable, createConfig(map));
+
+ SeaTunnelRow row = new SeaTunnelRow(new Object[] {1, "eng", "RetryUser", 25});
+
+ SeaTunnelException ex = assertThrows(SeaTunnelException.class, () -> writer.write(row));
+ assertTrue(
+ ex.getMessage()
+ .contains(
+ "Failed to write batch payload to Firebase after 2 attempts"));
+ }
+ }
+}
diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/firebase/FirebaseSinkIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/firebase/FirebaseSinkIT.java
new file mode 100644
index 0000000000..d54438dbc6
--- /dev/null
+++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/firebase/FirebaseSinkIT.java
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.e2e.connector.firebase;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.core.type.TypeReference;
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.Testcontainers;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.utility.DockerImageName;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+import java.time.Duration;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+public class FirebaseSinkIT extends TestSuiteBase implements TestResource {
+
+ private static final String FIREBASE_EMULATOR_IMAGE = "andreysenov/firebase-tools:latest";
+ private static final int REALTIME_DATABASE_EMULATOR_PORT = 9000;
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ private GenericContainer<?> firebaseEmulator;
+ private String emulatorHostUrl;
+ private int mappedPort;
+
+ @BeforeAll
+ @Override
+ public void startUp() throws Exception {
+ log.info("Starting Firebase Realtime Database Emulator container for Sink IT...");
+
+ String firebaseJson =
+ "{"
+ + " \"emulators\": {"
+ + " \"database\": {"
+ + " \"host\": \"0.0.0.0\","
+ + " \"port\": 9000"
+ + " }"
+ + " }"
+ + "}";
+
+ firebaseEmulator =
+ new GenericContainer<>(DockerImageName.parse(FIREBASE_EMULATOR_IMAGE))
+ .withExposedPorts(REALTIME_DATABASE_EMULATOR_PORT)
+ .withCommand(
+ "sh",
+ "-c",
+ "echo '"
+ + firebaseJson
+ + "' > firebase.json && firebase emulators:start --only database --project test-project")
+ .waitingFor(
+ org.testcontainers.containers.wait.strategy.Wait.forHttp("/.json")
+ .forStatusCode(200)
+ .withStartupTimeout(Duration.ofSeconds(60)))
+ .withLogConsumer(new Slf4jLogConsumer(log));
+
+ firebaseEmulator.start();
+
+ String host = firebaseEmulator.getHost();
+ this.mappedPort = firebaseEmulator.getMappedPort(REALTIME_DATABASE_EMULATOR_PORT);
+
+ Testcontainers.exposeHostPorts(mappedPort);
+ emulatorHostUrl = String.format("http://%s:%d", host, mappedPort);
+
+ log.info(
+ "Firebase Emulator initialized successfully for Sink IT at endpoint: {}",
+ emulatorHostUrl);
+ }
+
+ @TestTemplate
+ public void testFirebaseSink(TestContainer container) throws Exception {
+ log.info("Executing Firebase Sink E2E Job execution on container engine...");
+
+ // Include ?ns=test-project so HTTP requests from the sink append or target the correct
+ // emulator namespace
+ String targetUrl =
+ String.format("http://host.testcontainers.internal:%d?ns=test-project", mappedPort);
+
+ List<String> variables = Collections.singletonList("URL=" + targetUrl);
+
+ Container.ExecResult execResult =
+ container.executeJob("/fake_source_to_firebase.conf", variables);
+
+ Assertions.assertEquals(
+ 0,
+ execResult.getExitCode(),
+ "SeaTunnel job failed to execute. Error output: " + execResult.getStderr());
+
+ // Verify data was written correctly to Firebase Realtime Database
+ verifySinkData();
+
+ log.info("Firebase Sink E2E integration test executed and verified successfully.");
+ }
+
+ private void verifySinkData() {
+ String queryEndpointUrl = emulatorHostUrl + "/users.json?ns=test-project";
+
+ // Wait until records are available in the emulator
+ Awaitility.await()
+ .atMost(30, TimeUnit.SECONDS)
+ .pollInterval(1, TimeUnit.SECONDS)
+ .until(
+ () -> {
+ Map<String, Object> usersMap = fetchFirebaseData(queryEndpointUrl);
+ return usersMap != null && usersMap.size() >= 2;
+ });
+
+ Map<String, Object> users = fetchFirebaseData(queryEndpointUrl);
+ Assertions.assertNotNull(users, "Data read from Firebase should not be null");
+
+ // Verify specific key node creation (users/101 and users/102)
+ Assertions.assertTrue(users.containsKey("101"), "Firebase should contain key '101'");
+ Assertions.assertTrue(users.containsKey("102"), "Firebase should contain key '102'");
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> user101 = (Map<String, Object>) users.get("101");
+ Assertions.assertEquals(101, user101.get("id"));
+ Assertions.assertEquals("Alice", user101.get("name"));
+ Assertions.assertEquals(true, user101.get("is_active"));
+
+ log.info("Verified record contents for node 101 successfully.");
+ }
+
+ private Map<String, Object> fetchFirebaseData(String urlStr) {
+ HttpURLConnection connection = null;
+ try {
+ URL url = URI.create(urlStr).toURL();
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setRequestProperty("Accept", "application/json");
+ connection.setConnectTimeout(5000);
+ connection.setReadTimeout(5000);
+
+ if (connection.getResponseCode() == 200) {
+ try (InputStream is = connection.getInputStream()) {
+ return OBJECT_MAPPER.readValue(is, new TypeReference<Map<String, Object>>() {});
+ }
+ }
+ return null;
+ } catch (Exception e) {
+ log.warn(
+ "Failed to fetch data from Firebase Emulator at {}: {}",
+ urlStr,
+ e.getMessage());
+ return null;
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ @AfterAll
+ @Override
+ public void tearDown() throws Exception {
+ if (firebaseEmulator != null) {
+ log.info("Stopping Firebase Emulator container...");
+ firebaseEmulator.stop();
+ firebaseEmulator = null;
+ }
+ }
+}
diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/resources/fake_source_to_firebase.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/resources/fake_source_to_firebase.conf
new file mode 100644
index 0000000000..252909c6e8
--- /dev/null
+++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-firebase-e2e/src/test/resources/fake_source_to_firebase.conf
@@ -0,0 +1,62 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (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.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+env {
+ parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ FakeSource {
+ # 1. The 'schema' block is REQUIRED at top-level since 'tables_configs' is omitted
+ schema {
+ fields {
+ id = int
+ name = string
+ is_active = boolean
+ }
+ }
+
+ # 2. Hardcode the exact rows expected by verifySinkData() in FirebaseSinkIT.java
+ rows = [
+ {
+ kind = INSERT
+ fields = [101, "Alice", true]
+ },
+ {
+ kind = INSERT
+ fields = [102, "Bob", false]
+ }
+ ]
+
+ plugin_output = "fake"
+ }
+}
+
+transform {
+}
+
+sink {
+ Firebase {
+ url = ${URL}
+ path = "users"
+ primary_keys = ["id"]
+ batch_size = 10
+ retry_max = 3
+ timeout_ms = 10000
+ }
+}
\ No newline at end of file