Skip to content

[Feature][Connector-V2] Add Encharge source connector - #13704

Open
DanielLeens wants to merge 3 commits into
apache:devfrom
DanielLeens:codex-encharge-source-20261128
Open

DanielLeens wants to merge 3 commits into
apache:devfrom
DanielLeens:codex-encharge-source-20261128

Conversation

@DanielLeens

Copy link
Copy Markdown
Contributor

Yes, this contributes to Apache SeaTunnel.

Related to #10753.

What changed

Adds a bounded Encharge source for seven read families: people, account metadata, account tags, segments, person fields, custom-object schemas and segment membership. Native X-Encharge-Token authentication stays in the header at the fixed HTTPS origin. People/membership use limit/offset, while the other native collections remain unpaged. Anonymous people require no email/userId, and cross-segment membership is not deduplicated by email. Complete returned JSON and exact numeric identities are preserved without overwriting payload fields with parent context.

Segment membership automatically discovers bounded, distinct segment IDs; unselected segment records are not emitted. Discovery is committed only with complete page publication. Resource/parent/offset/publication positions and full-response digests allow exact suffix replay, deep-copy checkpoint isolation and zero-request terminal restoration. Numeric identity normalization checks precision/scale before exponent expansion.

The default public account view reads documented /accounts/info. An explicit legacy view retains the historical full-object /accounts contract, including any returned credential fields; it has no automatic fallback and is not in the current public specification. Live compatibility of that historical view remains unverified. The guide explains the data and access implications.

Includes isolated production/E2E modules, approved module/install/distribution registration, Factory SPI and bilingual guides/changelogs. Existing HTTP/Jackson versions are reused without new SDKs, shared framework changes or root dependency upgrades.

Validation

  • Scoped Java 11 Spotless apply/check passed for both modules.
  • Static checks covered 26 paths, 13 Java files, 22 documented types, all 14 options and bilingual tables, XML/ASF/whitespace and complete registration/state contracts. No Python files or existing capability deletions are included.
  • Authored 13 real Zeta E2E methods plus one packaged-reader entry with eight modes. An independent Java HTTPS peer checks all seven families, public/explicit historical account views, anonymous people, cross-segment context, hidden/duplicate discovery, precise large/decimal/zero/negative IDs, exponent limits, unpaged and fixed-offset traversal, page/row/discovery caps, malformed shapes, retries, byte/parser/media limits, TLS, deadlines and socket closure before cleanup. Four real engine savepoint paths cover segment discovery, parent switching, offsets and terminal recovery; packaged modes cover partial people/directory/membership replay, raw-envelope changes, object reordering, copy isolation and zero-work invalid scope/state.
  • Compilation, E2E execution and runtime results remain pending GitHub CI. No local compilation, tests, containers, fixture services or live account run was performed.

Provider permissions, live-list mutation and compatibility of the explicitly selected historical account view remain external constraints. This source is neither a transaction snapshot nor a watermark shared by independent batch jobs.

@DanielLeens

Copy link
Copy Markdown
Contributor Author

Implementation Notes and Trade-offs

Head: 50a0d70

Seven resource families have distinct response/continuation contracts. People and membership use native offset arrays; tags, segments, fields and schemas are unpaged collections; account metadata is one object. Reusing one pagination/envelope shape for all of them was rejected because it would invent unsupported query parameters or misread singleton data. Full raw people-page size drives continuation, and over-budget continuation fails rather than truncates.

The fixed HTTPS origin uses native X-Encharge-Token for an account-owned integration. Arbitrary URLs, redirects and key-in-query delivery are not used. Anonymous people retain their native IDs without requiring email, and the same person can remain in multiple segments. A separate segment_id column supplies parent ownership without mutating returned JSON. Exact decimal normalization avoids double rounding; precision/scale bounds run before plain-number expansion, preventing extreme exponent IDs from causing disproportionate allocation.

The generic HTTP source was considered but does not provide bounded segment discovery or exact dependency/page checkpoint replay. An isolated artifact reuses existing HTTP/Jackson versions and keeps the behavior outside shared engine/API code. Duplicate segment records remain data while discovered parents are unique. Discovery for a page is committed with its completed publication transition, so a partial snapshot keeps preceding identities and a complete-page fingerprint. Replay compares the whole raw response before suffix output or discovery changes. Object-key reordering is accepted; changed content, array order or envelope fields fails. Identity lists are deep-copied for assignment/snapshots. Committed discovery, parent and offset transitions do not replay completed work, and terminal restore issues no request.

The documented public /accounts/info view is the default. Silently treating it as field-equivalent to the historical full /accounts object was rejected. The explicit legacy option preserves that separate contract, including returned account credential fields, without an automatic fallback. It is absent from the current public specification and has not been checked against a live account; operators must have compatible access and protect that output. The guides state this boundary rather than claiming current public coverage for the historical endpoint.

Actual validation: scoped Java 11 Spotless apply/check, source review, exact path/hash/deletion/ASF/whitespace checks, 22 type Javadocs, 14 option tables and full dependency/SPI/packaging/state contracts. Thirteen engine methods and eight packaged modes were authored, including four real savepoint paths. None ran locally. Compilation, runtime and live-provider interoperability remain pending GitHub CI; subsequent CI/comment maintenance is handed off after this initial readback. Account permissions and mutable offset lists remain external constraints, and no merge, production-readiness, transaction-snapshot or cross-job watermark claim is made.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing Encharge support to Apache SeaTunnel. I read the complete current diff and followed its native resource, dependency, publication, replay and cancellation paths. The distinct response shapes and explicit account-view boundary are useful. The publication and fixture/delivery issues below need attention before merging. This is a maintainer-style COMMENT on Daniel's own PR, not independent approval.

What problem does this PR solve?

User pain. Account exports combine paged people/membership lists, unpaged directories and singleton account metadata; treating every resource as the same envelope loses data or invents requests.

Fix. Add seven native read families with explicit account views, bounded segment discovery and complete-page replay verification.

Example and summary. Selecting segment_people discovers segments without emitting an unwanted directory, then keeps the same anonymous person in each actual segment. Restore of32out of33published records verifies the complete envelope before emitting only the suffix.

1. Code changes

1.1 Core logic

Complete runtime path:

Factory/SPI -> typed SourceOptions/Config -> BATCH bounded Source
 -> active reader0; additional subtasks finish idle
 -> async Api.read -> fixed api.encharge.io/v1 GET with X-Encharge-Token
 -> people/all or segments/{id}/people offset pages
 -> unpaged tags/segments/fields/schemas or singleton account metadata
 -> validate full raw envelope/identities -> bound segment discovery
 -> canonical complete-envelope digest -> locked32row publication
 -> commit discovered segments with completed page -> offset/parent/resource transition
 -> copied scope/IDs/numeric position -> refetch partial page -> verify then suffix
 -> terminal no HTTP; cancellation closes socket/watchdog/fetch worker
Separate completed pipeline -> job savepoint prerequisite (Issue4)

Key findings and correctness:

  1. Read all26changed files, complete production/tests/docs/resources and full author note. The official REST entry links ReDoc, whose downloaded merged.yaml confirms all seven current paths, the account-owned X-Encharge-Token alternative, people limit/offset, four distinct array keys and singleton accounts/info. No live account was contacted.
  2. The public specification omits historical /accounts; the code deliberately gates it behind explicit legacy selection and both guides disclose unsupported-current-public/live interoperability and credential-bearing output. Default public account metadata is separate. This is an external availability limit, not evidence that default requests use the wrong route.
  3. Numeric account/segment IDs are number-shaped in the native schema, not necessarily integers. Exact BigDecimal canonicalisation retains large values/decimal/negative/zero within checked length/scale bounds before toPlainString. People IDs remain text; anonymous email/userId are not required, and memberships are not deduplicated across parents. No provider URL is followed.
  4. Raw people count drives offset continuation; unpaged arrays are bounded by max_rows_per_response rather than page_size. Segment dependencies are unique for expansion, while selected duplicate segment records remain visible. Discovery commits only with full-page publication. Full raw-envelope hash includes metadata and unselected dependency records; object-key reordering alone is accepted. State binds key/resources/account view/page size and copies identity lists. Lists remain live, not transactional snapshots or cross-job CDC.
  5. Wire/decoded/UTF8/JSON/attempt/operation limits, bounded eligible GET retries and raw-socket cancellation avoid publication locks.32synchronous collect calls retain Issue1. SourceOptions, both completion callbacks and bilingual ChangeLog hooks are correct. The copied frozen-date-window comments are inaccurate and included in Issue5.

Before: no native Encharge source or saved segment/offset state.

After:

int stop = Math.min(page.rows.size(), progress.row + ROWS_PER_POLL);
while (!closed && progress.row < stop) {
    output.collect(page.rows.get(progress.row));
    ++progress.row;
    progress.digest = page.digest;
}

The collector checkpoint and progress monitors span this32row chunk; the page transition then commits discovered segments.

1.2 Compatibility

Additive isolated connector; existing APIs/options/defaults/protocols/serialized contracts remain unchanged. UID1 state is private to this unreleased connector and binds account key/resources/view/page size. Credentials/raw records/certificates are excluded from state. Existing HTTP/Jackson versions are reused; no released-state migration is established.

1.3 Performance and side effects

One active scan retains a capped segment set and complete response. Canonical sorting/hash, JSON trees and independent list copies add bounded per-response CPU/allocation; configured caps are not total heap guarantees. One fetch worker plus watchdog; network waits avoid checkpoint locks but32collect calls do not. Cancel closes the owned raw socket and executors.

1.4 Errors, logging, and findings

Issue 1: Yield checkpoint handoff between rate-limited output rows

  • Location: seatunnel-connectors-v2/connector-http/connector-http-encharge/src/main/java/org/apache/seatunnel/connectors/seatunnel/encharge/EnchargeReader.java:122.
  • Description and risk: The collector and progress monitors cover up to32 synchronous output.collect calls. SeaTunnelSourceCollector:307 invokes FlowControlGate.audit and the row limiter acquires at FlowControlGate:46-48. A supported1row/s job can spend about31seconds in the chunk, exceeding an explicit10second checkpoint timeout before SourceFlowLifeCycle:299-321 can hand off its barrier. Moving HTTPS outside the monitor does not bound emission latency.
  • Best improvement: Publish one row per poll or use a supported engine handoff between rows while atomically retaining the precise publication position. Add a throttled multirow-page Zeta checkpoint/restore regression below the old chunk duration.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: High; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 2: Use the same cancellation marker in the peer and assertions

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:549.
  • Description and risk: The cancellation tests and trickling-data deadline test wait for .disconnected; EnchargePeer:301 writes .disconnect on IOException. Nothing writes the observed filename, so these conditions deterministically expire even when transport closure works. This is a fixture mismatch established from source, not a claim of local execution.
  • Best improvement: Use one shared marker spelling for both observers and the peer; retain active writes that can detect socket closure before finally releases the fixture.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: High; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 3: Update new Java and configuration routing aliases

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:979.
  • Description and risk: The Java-built source and two new configurations use result_table_name/source_table_name outside the legacy allowlist. AllFileSpecificationCheckTest:130-137 rejects these names in both Java and conf. SourceOptions naming, bilingual ChangeLog hooks and both checkpoint completion callbacks are already correct.
  • Best improvement: Use plugin_output/plugin_input for every new alias, preserving routing, assertions and both terminal pipelines.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: Medium; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 4: Resolve the completed-pipeline savepoint prerequisite

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:697.
  • Description and risk: The terminal configuration has separate connector/LocalFile and live FakeSource/Console pipelines. After the bounded pipeline finishes, the test requests a job savepoint. Current CheckpointManager:251-265 visits every coordinator, but CheckpointCoordinator:936-940 rejects the completed one. Owning #13509 remains open/unmerged in the checked base. The packaged terminal-reader zero-request probe is independently useful.
  • Best improvement: Use a supported shared-pipeline anchor, or wait for the owning engine capability to land and refresh the branch. Retain terminal identity/output/no-request assertions without importing unrelated engine work.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: Medium; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 5: Document page/discovery transitions and mutable-state contracts

  • Location: seatunnel-connectors-v2/connector-http/connector-http-encharge/src/main/java/org/apache/seatunnel/connectors/seatunnel/encharge/EnchargeReader.java:133.
  • Description and risk: finishPage/awaitPage, API fingerprint/navigation and inaccurate frozen-date-window wording (there is no date window in this source), split.copy and nontrivial mutable identity/counter/digest fields need focused contracts explaining when discovered relationships become committed, which monitor protects publication, and why assignment/snapshot copies cannot alias. Class summaries alone do not describe these separate core invariants.
  • Best improvement: Add concise method/field contracts for lock ownership, complete-page verification, parent/page resets and independent snapshot lists; keep executable behavior unchanged.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: Medium; blocking: true.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Issue 6: Match held-response lifetimes to the full observation budget

  • Location: seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:796.
  • Description and risk: Held savepoint requests use a30second attempt with zero retries, while start/checkpoint observation can consume30+35seconds before the savepoint. Active trickles stop after45seconds while cancellation observations permit30+30+10seconds. On a loaded runner the fixture may leave the intended state before the action being checked.
  • Best improvement: Set explicit test-only request/peer deadlines from the total observation budget, retaining bounded waits and finally-owned release/cancel.
  • Responsibility and trade-off: Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.
  • Severity: Medium; blocking: false.
  • Previously raised by another reviewer: No, unless explicitly attributed above.

Only the author implementation note was present; no independent technical reviewer finding or maintainer approval/change request to duplicate. Its authored validation claims were read, not reproduced.

2. Code quality

2.1 Conventions

Reviewed all changed files for license, imports, naming, core-method and state-field comments. See the numbered findings for the required changes.

2.2 Test coverage and stability

Stability rating: High risk. Thirteen authored engine methods and eight packaged modes cover seven response shapes, anonymous/cross-segment records, explicit legacy/public views, full JSON/numeric identity, discovery/offset bounds, malformed successes/TLS/retries/deadlines, complete-envelope mutations, copied serialized state, discovery/parent/offset savepoints and terminal zero work. High risk at seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:549 due to deterministic Issue2; terminal topology needs Issue4 and held-response budgets need Issue6. No local compilation, UT/IT/E2E, engine, peer or provider request ran.

2.3 Documentation

EN/ZH match all seven native response shapes, connector-only page cap, real segment discovery, exact numeric IDs, explicit legacy sensitive-output/availability limits, mutable-list/replay boundaries and key binding. Both guides include ChangeLog hooks and an environment-key example. Correct the focused fixture aliases and core comments without broadening capability claims.

3. Architecture

3.1 Change location

Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.

3.2 Maintainability

Keep the behavior, lifecycle ownership, and failure contract together. Keep native resource/discovery/replay and fixtures connector-local. The completed-pipeline engine capability remains owned by #13509.

3.3 Extensibility

Prefer the existing component boundary and tests over unrelated shared abstractions.

3.4 Upgrade impact

Additive isolated connector; existing APIs/options/defaults/protocols/serialized contracts remain unchanged. UID1 state is private to this unreleased connector and binds account key/resources/view/page size. Credentials/raw records/certificates are excluded from state. Existing HTTP/Jackson versions are reused; no released-state migration is established.

4. Findings summary

Completeness check: All changed files and affected entry/failure paths were reviewed; configuration/serialization compatibility, test failure capability and stability, documentation/examples, change ownership, and current CI/conflict/review gates are covered above. No unreviewed source scope is claimed complete.

# Finding Location Severity
1 Yield checkpoint handoff between rate-limited output rows seatunnel-connectors-v2/connector-http/connector-http-encharge/src/main/java/org/apache/seatunnel/connectors/seatunnel/encharge/EnchargeReader.java:122 High
2 Use the same cancellation marker in the peer and assertions seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:549 High
3 Update new Java and configuration routing aliases seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:979 Medium
4 Resolve the completed-pipeline savepoint prerequisite seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:697 Medium
5 Document page/discovery transitions and mutable-state contracts seatunnel-connectors-v2/connector-http/connector-http-encharge/src/main/java/org/apache/seatunnel/connectors/seatunnel/encharge/EnchargeReader.java:133 Medium
6 Match held-response lifetimes to the full observation budget seatunnel-e2e/seatunnel-connector-v2-e2e/connector-encharge-e2e/src/test/java/org/apache/seatunnel/e2e/connector/encharge/EnchargeIT.java:796 Medium

5. Merge recommendation

Merge after fixes

Blocking items: Issues 1, 2, 3, 4, 5. Current-head CI and write-capable maintainer review remain independent requirements.

Non-blocking suggestions: Issue 6: Match held-response lifetimes to the full observation budget

Overall: the approach addresses a real path, but the listed blockers must be closed. Daniel has READ permission, so this COMMENT cannot dismiss historical requested changes or satisfy a write-capable maintainer approval gate.

CI and repository state: no check reported in the Apache rollup; Build: queued. GitHub reports BLOCKED / REVIEW_REQUIRED.

Verification: Reviewed all changed files and the referenced call sites at 50a0d707f5e065e22c3736d7a0bf81256d48b817 against merge base 0bef81d003a9dcc3266a10140dc639534ad81bfd. git diff --check passed. I did not build, run tests, or execute SeaTunnel locally.

Review time: 2026-11-28T20:11:25.826832-05:00

Local evidence: git fetch obtained head 50a0d707f5e065e22c3736d7a0bf81256d48b817; git merge-base returned 0bef81d003a9dcc3266a10140dc639534ad81bfd; git diff --stat reports 26 files changed, 4054 insertions(+). git show and source searches were used for the entry points above. No local build, unit test, E2E, Docker run or service startup was executed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant