jason810496 commented on code in PR #65956:
URL: https://github.com/apache/airflow/pull/65956#discussion_r3158510441


##########
java-sdk/adr/0003-workload-execution.md:
##########
@@ -0,0 +1,473 @@
+<!--
+ 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.
+ -->
+
+# ADR-0003: Workload Execution — Language-Specific Task Execution
+
+## Status
+
+Accepted
+
+## Context
+
+Airflow's standard task runner executes Python callables. To support tasks 
written in other languages, the pipeline needs an extension point where a 
language-specific coordinator can intercept the execution, delegate to an 
external runtime process, and bridge the Task SDK protocol so the external 
process can access Airflow services (connections, variables, XCom) during 
execution.
+
+This ADR details the task execution side of the coordinator architecture 
described in [ADR-0001](0001-java-sdk-airflow-integration.md). It starts with 
the generic model — the abstract contracts and expected behavior that any 
language must implement — then walks through Java as a concrete example.
+
+## Decision
+
+### Extension Point: `BaseCoordinator`
+
+The same `BaseCoordinator` base class that handles DAG parsing also handles 
task execution. It is registered in `provider.yaml` under `coordinators`. For 
task execution, a subclass must implement:
+
+| Method | Signature | Responsibility |
+|---|---|---|
+| `task_execution_cmd` | `(what, dag_rel_path, bundle_info, comm_addr, 
logs_addr) -> list[str]` | Return the full command to launch the language 
runtime for task execution. `comm_addr` and `logs_addr` are `host:port` strings 
the process must connect to. |
+
+The base class provides `run_task_execution()` as a concrete method that 
handles all TCP/process plumbing automatically (same pattern as 
`run_dag_parsing()` for the DAG parsing side).
+
+**Parameters passed to `run_task_execution()`:**
+
+| Parameter | Type | Description |
+|---|---|---|
+| `what` | `TaskInstance` | The task instance to execute (id, dag_id, task_id, 
run_id, try_number, etc.) |
+| `dag_rel_path` | `str \| PathLike` | Relative path to the DAG file / bundle 
within the bundle root |
+| `bundle_info` | `BundleInfo` | Bundle name and version |
+| `startup_details` | `StartupDetails` | Full startup context (task instance, 
DAG rel path, bundle info, run context, start date) — already consumed from fd 
0 |
+
+### Registration
+
+The same `coordinators` entry in `provider.yaml` covers both DAG parsing and 
task execution — no separate registration needed:
+
+```yaml
+coordinators:
+  - airflow.providers.sdk.<lang>.coordinator.<LangCoordinator>
+```
+
+### Discovery: `_resolve_runtime_entrypoint()`
+
+When `task_runner.main()` starts, before any Python task execution:
+
+```
+task_runner.main()

Review Comment:
   > I would not assume every runner would be capable of running all languages. 
I'd assume I need to deploy a worker with a JDK installed that can run Java 
tasks but that one might not execute Go code.
   
   That's correct. Only if the `sdk.<lang>` provider is installed on that 
runner then it will be able to leverage the corresponding coordinator.
   
   > So we should be able to configure (per worker potentially) which SDK 
coordinators are supported.
   
   There's `[sdk] queue_to_sdk = '{"foo": "java", "bar": "java", "go-queue": 
"go"}'` config, which _should_ match what you mentioned here.
   
   > (e.g. JAR of tasks must be available at respective worker in the right 
version as well)
   
   Yes, the `Airflow-Java-SDK-Version` metadata in JAR should match the 
corresponding Java coordinator version. (Though I haven't added the validation 
for this one)
   
   
https://github.com/apache/airflow/pull/65958/changes#diff-7b5ede5793d4407e3d13b6bb0d6db4f11586fe5eebfe66c74b700fe3edf16f16R38



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to