From 12ae6958e39943943043aeece5153e29af7cf4fd Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 11:53:19 +0530 Subject: [PATCH 1/6] CONTNM-137: Update docs to use template for creating new feature workers --- .../contributing/create-new-nodes/overview.md | 70 +++-- .../create-new-nodes/step-1-clone-and-run.md | 75 ++++++ .../create-new-nodes/step-1-root-project.md | 53 ---- .../create-new-nodes/step-2-feature-module.md | 66 ----- .../step-2-tour-the-template.md | 127 +++++++++ .../create-new-nodes/step-3-make-it-yours.md | 110 ++++++++ .../create-new-nodes/step-3-write-the-node.md | 179 ------------- .../step-4-node-documentation.md | 20 -- .../step-4-write-your-node.md | 253 ++++++++++++++++++ .../create-new-nodes/step-5-test-and-run.md | 63 +++++ .../create-new-nodes/step-5-unit-tests.md | 53 ---- .../create-new-nodes/step-6-ship-it.md | 91 +++++++ .../create-new-nodes/step-6-worker-module.md | 100 ------- .../create-new-nodes/step-7-build-and-test.md | 26 -- .../create-new-nodes/step-8-run-locally.md | 27 -- .../create-new-nodes/step-9-ship-it.md | 16 -- .../create-new-nodes/troubleshooting.md | 29 +- docs/contributing/feature-template.md | 2 +- .../contributing/create-new-nodes/overview.md | 70 +++-- .../create-new-nodes/step-1-clone-and-run.md | 75 ++++++ .../create-new-nodes/step-1-root-project.md | 53 ---- .../create-new-nodes/step-2-feature-module.md | 66 ----- .../step-2-tour-the-template.md | 127 +++++++++ .../create-new-nodes/step-3-make-it-yours.md | 110 ++++++++ .../create-new-nodes/step-3-write-the-node.md | 179 ------------- .../step-4-node-documentation.md | 20 -- .../step-4-write-your-node.md | 253 ++++++++++++++++++ .../create-new-nodes/step-5-test-and-run.md | 63 +++++ .../create-new-nodes/step-5-unit-tests.md | 53 ---- .../create-new-nodes/step-6-ship-it.md | 91 +++++++ .../create-new-nodes/step-6-worker-module.md | 100 ------- .../create-new-nodes/step-7-build-and-test.md | 26 -- .../create-new-nodes/step-8-run-locally.md | 27 -- .../create-new-nodes/step-9-ship-it.md | 16 -- .../create-new-nodes/troubleshooting.md | 29 +- .../contributing/feature-template.md | 2 +- versions.json | 4 +- 37 files changed, 1549 insertions(+), 1175 deletions(-) create mode 100644 docs/contributing/create-new-nodes/step-1-clone-and-run.md delete mode 100644 docs/contributing/create-new-nodes/step-1-root-project.md delete mode 100644 docs/contributing/create-new-nodes/step-2-feature-module.md create mode 100644 docs/contributing/create-new-nodes/step-2-tour-the-template.md create mode 100644 docs/contributing/create-new-nodes/step-3-make-it-yours.md delete mode 100644 docs/contributing/create-new-nodes/step-3-write-the-node.md delete mode 100644 docs/contributing/create-new-nodes/step-4-node-documentation.md create mode 100644 docs/contributing/create-new-nodes/step-4-write-your-node.md create mode 100644 docs/contributing/create-new-nodes/step-5-test-and-run.md delete mode 100644 docs/contributing/create-new-nodes/step-5-unit-tests.md create mode 100644 docs/contributing/create-new-nodes/step-6-ship-it.md delete mode 100644 docs/contributing/create-new-nodes/step-6-worker-module.md delete mode 100644 docs/contributing/create-new-nodes/step-7-build-and-test.md delete mode 100644 docs/contributing/create-new-nodes/step-8-run-locally.md delete mode 100644 docs/contributing/create-new-nodes/step-9-ship-it.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-root-project.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-feature-module.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-write-the-node.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-node-documentation.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-unit-tests.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-worker-module.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-7-build-and-test.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-8-run-locally.md delete mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/step-9-ship-it.md diff --git a/docs/contributing/create-new-nodes/overview.md b/docs/contributing/create-new-nodes/overview.md index 7c53887..00cfffd 100644 --- a/docs/contributing/create-new-nodes/overview.md +++ b/docs/contributing/create-new-nodes/overview.md @@ -7,62 +7,58 @@ slug: /contributing/create-new-nodes # Create New Nodes -This guide walks you through building a **feature worker** with your own workflow node, from an empty folder to a passing build and a worker that registers its node with the platform. The running example is a **Word Counter** node that counts the words in a text column and appends the count as a new column. + + +Start from the **`continuum-feature-template`** repository, rename it, replace its example node with yours, and ship a worker. You write one Kotlin or Java class per node. The template provides everything else. + + - Kotlin + Gradle - 9 steps + Kotlin or Java + 6 steps Platform 0.0.20 -You need to know some Kotlin and Gradle. You don't need to know Temporal, Kafka or Spring internals; the Continuum Gradle plugins and the worker starter handle those. +## The idea in one minute -:::info[Versions used in this guide] -Verified against **Continuum platform `0.0.20`** (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Check [Maven Central](https://central.sonatype.com/artifact/org.projectcontinuum.core/continuum-commons) for the latest platform version, and use the same version everywhere in your project. -::: +A **node** is a block on the Workbench canvas that reads tables, does something and writes tables. Nodes live in a **feature worker**, a small Spring Boot app that registers its nodes with the platform at startup. -## How the pieces fit +You don't build a worker from scratch. The template is already a complete, working worker with two example nodes, a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. -A feature worker is a small Gradle multi-project: - -``` -continuum-feature-demo/ -├── settings.gradle.kts # plugin versions + module list -├── gradle.properties # continuumPlatformVersion, featureVersion -├── features/ -│ └── continuum-feature-demo/ # library module: your node classes -└── worker/ # thin Spring Boot app that hosts the nodes +```mermaid +flowchart LR + S1["1
Clone and run"] --> S2["2
Tour"] --> S3["3
Rename"] --> S4["4
Write your node"] --> S5["5
Test and run"] --> S6["6
Ship"] ``` -- **Feature modules** (`org.projectcontinuum.feature` plugin) hold the node classes. They're plain libraries and can be published and reused. -- **The worker module** (`org.projectcontinuum.worker` plugin) is a Spring Boot app with no node logic of its own. It depends on your feature modules and on `continuum-worker-springboot-starter`. At startup the starter finds every `@ContinuumNode` bean, polls a Temporal task queue for node executions, and publishes one registration message per node to Kafka. - -See [Node Model & Feature Registration](../../architecture/node-model.md) for what happens after registration. - -## Prerequisites +## What you need | Requirement | Notes | |-------------|-------| -| JDK 21 | Eclipse Temurin recommended. The plugins set a Java 21 toolchain. | -| Gradle wrapper 8.14+ | Older wrappers (for example 8.4) can't load the Spring Boot 4 Gradle plugin. | -| Docker | Only needed to run the worker against the [local stack](../../getting-started/local-setup.md). | +| JDK 21 | Eclipse Temurin recommended. | +| Docker and Compose | Runs the local Continuum stack, about 8 GB of RAM. | +| Some Kotlin or Java | You don't need to know Temporal, Kafka or Spring internals. | -You **don't** need a GitHub token. All Continuum artifacts and Gradle plugins are published to **Maven Central**. +You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. ## The steps -1. [Create the root project](./step-1-root-project.md) -2. [Create the feature module](./step-2-feature-module.md) -3. [Write the node](./step-3-write-the-node.md) -4. [Add node documentation](./step-4-node-documentation.md) -5. [Write unit tests](./step-5-unit-tests.md) -6. [Create the worker module](./step-6-worker-module.md) -7. [Build and test](./step-7-build-and-test.md) -8. [Run the worker against the local stack](./step-8-run-locally.md) -9. [Ship it](./step-9-ship-it.md) +1. [Clone the template and run it](./step-1-clone-and-run.md): see the example nodes working before you change anything. +2. [Tour the template](./step-2-tour-the-template.md): which files you write, which you rename and which you leave alone. +3. [Make it yours](./step-3-make-it-yours.md): a checklist for renaming the project, packages, worker and chart. +4. [Write your node](./step-4-write-your-node.md): the node class, its help page and its unit test. +5. [Test and run your node](./step-5-test-and-run.md): build, run the worker and use your node in the Workbench. +6. [Ship it](./step-6-ship-it.md): versions, CI, release and Kubernetes. -If something goes wrong along the way, see [Troubleshooting](./troubleshooting.md). +## Where to look when something breaks + +- Your node doesn't appear in the Workbench: [Troubleshooting](./troubleshooting.md). +- The platform's side of registration: [Node Model & Feature Registration](../../architecture/node-model.md). +- The template's own README and `AGENTS.md` list its commands and rules. + +:::info[Versions] +Verified against **Continuum platform `0.0.20`** (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Check [Maven Central](https://central.sonatype.com/artifact/org.projectcontinuum.core/continuum-commons) for newer versions. +::: diff --git a/docs/contributing/create-new-nodes/step-1-clone-and-run.md b/docs/contributing/create-new-nodes/step-1-clone-and-run.md new file mode 100644 index 0000000..1bb1f20 --- /dev/null +++ b/docs/contributing/create-new-nodes/step-1-clone-and-run.md @@ -0,0 +1,75 @@ +--- +sidebar_position: 2 +sidebar_label: "1. Clone and run" +title: "Step 1: Clone the template and run it" +--- + +# Step 1: Clone the template and run it + + + Step 1 of 6 + About 10 minutes + + +Before you change anything, get the unmodified template running. You'll see the two example nodes on a canvas, and from then on you know that any breakage comes from your own changes. + +## 1. Get the code + +On GitHub, open [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) and click **Use this template**. That creates a copy in your own organisation without the template's git history. Then clone your copy: + +```bash +git clone https://github.com//.git +cd +``` + +## 2. Build it + +```bash +./gradlew build +``` + +This compiles both example modules, runs their unit tests, checks that every node is annotated correctly and packages the worker jar. The Gradle wrapper is already in the repo; you only need JDK 21. + +## 3. Start the local Continuum stack + +```bash +cd docker +docker compose up -d +``` + +Wait until `docker compose ps` shows the services as healthy. The `temporal-search-attributes-init` container exits when its setup is done; that's expected. The stack needs about 8 GB of RAM. + +## 4. Start your worker + +From the repository root: + +```bash +./gradlew :worker:bootRun +``` + +The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. + +## 5. See your nodes in the Workbench + +1. Open the Workbench at [http://localhost:3002](http://localhost:3002). +2. In the node palette, find **Hello World** and **Hello Java** under **Examples**. +3. Drag a table source onto the canvas (for example **Create Table**), connect it to **Hello World**, and run the workflow. + +Each row gets a new `greeting` column. + +:::tip[It worked if you see the nodes] +If the palette is empty, the worker didn't register. Check [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health) and see [Troubleshooting](./troubleshooting.md). +::: + +## Local endpoints + +| Service | URL | +|---------|-----| +| Workbench | [http://localhost:3002](http://localhost:3002) | +| API server | [http://localhost:8080](http://localhost:8080) | +| Your worker | [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health) | +| Temporal UI | [http://localhost:38081](http://localhost:38081) | +| Kafka UI | [http://localhost:38082](http://localhost:38082) | +| MinIO console | [http://localhost:39001](http://localhost:39001) (`minioadmin` / `minioadmin`) | + +Next: [take a tour of what you just ran](./step-2-tour-the-template.md). diff --git a/docs/contributing/create-new-nodes/step-1-root-project.md b/docs/contributing/create-new-nodes/step-1-root-project.md deleted file mode 100644 index 084424a..0000000 --- a/docs/contributing/create-new-nodes/step-1-root-project.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -sidebar_position: 2 -sidebar_label: "1. Root project" -title: "Step 1: Create the root project" ---- - -# Step 1: Create the root project - - - Step 1 of 9 - 11% through the guide - - -Create the folder and add a Gradle wrapper. If Gradle is installed, run `gradle wrapper --gradle-version 8.14`. Otherwise, copy `gradlew`, `gradlew.bat` and `gradle/wrapper/` from an existing feature repo such as `continuum-feature-base`. - -**`gradle.properties`** - -```properties -repoName=your-org/continuum-feature-demo -continuumPlatformVersion=0.0.20 -featureVersion=0.0.1 - -# Spring Boot 4 pulls in a large Kotlin compiler jar; give the Gradle daemon enough heap. -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -``` - -- `continuumPlatformVersion` selects the Gradle plugin version and the `continuum-commons` / `continuum-worker-springboot-starter` versions. -- `featureVersion` is your own version. -- `repoName` is used in published POM metadata and in the default container image name. - -**`settings.gradle.kts`** - -```kotlin -pluginManagement { - val continuumPlatformVersion: String by settings - repositories { - mavenLocal() - mavenCentral() - gradlePluginPortal() - } - plugins { - id("org.projectcontinuum.feature") version continuumPlatformVersion - id("org.projectcontinuum.worker") version continuumPlatformVersion - } -} - -rootProject.name = "continuum-feature-demo" - -include(":features:continuum-feature-demo") -include(":worker") -``` - -The plugins are resolved from Maven Central, so `mavenCentral()` must be in `pluginManagement.repositories`, not only in `gradlePluginPortal()`. diff --git a/docs/contributing/create-new-nodes/step-2-feature-module.md b/docs/contributing/create-new-nodes/step-2-feature-module.md deleted file mode 100644 index 77d01b7..0000000 --- a/docs/contributing/create-new-nodes/step-2-feature-module.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -sidebar_position: 3 -sidebar_label: "2. Feature module" -title: "Step 2: Create the feature module" ---- - -# Step 2: Create the feature module - - - Step 2 of 9 - 22% through the guide - - -**`features/continuum-feature-demo/build.gradle.kts`** - -```kotlin -plugins { - id("org.projectcontinuum.feature") -} - -group = "org.projectcontinuum.feature.demo" -description = "Continuum Feature Demo — demo nodes" -version = property("featureVersion").toString() - -continuum { - continuumVersion.set(property("continuumPlatformVersion").toString()) -} -``` - -:::warning[Always set `continuumVersion`] -If you leave out the `continuum { }` block, the plugin falls back to a built-in default version that is older than the plugin itself. Read the value from `gradle.properties` so plugins and libraries always match. -::: - -The `org.projectcontinuum.feature` plugin applies Kotlin and Spring dependency management and adds these dependencies for you, so you don't declare them yourself: - -- Spring Boot starter, web, actuator and autoconfigure -- `continuum-commons` -- `kotlin-reflect` and `tools.jackson.module:jackson-module-kotlin` -- Test: `spring-boot-starter-test`, `kotlin-test-junit5`, `mockito-kotlin` - -It also registers the `validateContinuumNodeAnnotations` task, which runs before `classes`. Add a `dependencies { }` block only for extra libraries your nodes need. - -## Register the module with Spring - -The worker finds your nodes through Spring Boot auto-configuration, so each feature module needs two small files. - -**`src/main/kotlin/org/projectcontinuum/feature/demo/AutoConfigure.kt`** - -```kotlin -package org.projectcontinuum.feature.demo - -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.Configuration - -@Configuration -@ComponentScan -class AutoConfigure -``` - -**`src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`** - -```text -org.projectcontinuum.feature.demo.AutoConfigure -``` - -`@ComponentScan` with no arguments scans the package of `AutoConfigure` and its subpackages. If the imports file is missing or names the wrong class, the build still passes but the worker starts with none of your nodes. diff --git a/docs/contributing/create-new-nodes/step-2-tour-the-template.md b/docs/contributing/create-new-nodes/step-2-tour-the-template.md new file mode 100644 index 0000000..83a3b07 --- /dev/null +++ b/docs/contributing/create-new-nodes/step-2-tour-the-template.md @@ -0,0 +1,127 @@ +--- +sidebar_position: 3 +sidebar_label: "2. Tour the template" +title: "Step 2: Tour the template" +--- + +# Step 2: Tour the template + + + Step 2 of 6 + About 5 minutes + + +The template has about 40 files, but you will only write code in a handful of them. This page shows which ones, and why the rest exist. + +## The big picture + +Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. + +```mermaid +flowchart LR + W["worker/
The app you run and deploy.
No node logic."] + W -->|loads| K["features/continuum-feature-hello
Nodes in Kotlin"] + W -->|loads| J["features/continuum-feature-hello-java
Nodes in Java"] +``` + +At startup the worker finds every class annotated with `@ContinuumNode`, listens on its own Temporal task queue for work, and announces each node to the platform so it shows up in the Workbench palette. + +## Where things are + +Each file or folder below is tagged with what you need to do with it. + +| Tag | Meaning | +|-----|---------| +| **Write** | Your code goes here. You'll edit or add files. | +| **Rename once** | Contains the template's name. Change it in [Step 3](./step-3-make-it-yours.md), then forget about it. | +| **Keep in sync** | Several files must agree. If you change one, change the others. | +| **Leave alone** | Works as shipped. | + +```text +continuum-feature-template/ +├── gradle.properties Keep in sync platform + feature versions +├── settings.gradle.kts Rename once project name + list of modules +├── build.gradle.kts Leave alone +│ +├── features/ +│ └── continuum-feature-hello/ Rename once a feature module (Kotlin) +│ ├── build.gradle.kts Rename once group, description +│ └── src/ +│ ├── main/kotlin/…/example/ +│ │ ├── AutoConfigure.kt Rename once tells Spring where your nodes are +│ │ └── node/ +│ │ └── HelloWorldNodeModel.kt Write ← your node +│ ├── main/resources/ +│ │ ├── META-INF/spring/…AutoConfiguration.imports Rename once +│ │ └── …/node/HelloWorldNodeModel.doc.md Write ← help page +│ └── test/kotlin/…/HelloWorldNodeModelTest.kt Write ← unit test +│ +├── features/continuum-feature-hello-java/ Delete if you only write Kotlin (same layout) +│ +├── worker/ +│ ├── build.gradle.kts Keep in sync which modules the worker loads, image name +│ └── src/main/ +│ ├── kotlin/…/App.kt Leave alone Spring Boot entry point +│ └── resources/application.yaml Keep in sync task queue, app name +│ +├── charts/continuum-feature-template/ Keep in sync Helm chart for Kubernetes +├── docker/ Leave alone local Continuum stack +└── .github/workflows/ Keep in sync CI and release (lists your modules) +``` + +## The files that matter + +### Files you write + +These three live side by side in each feature module and share a name: + +| File | What it is | +|------|------------| +| `node/HelloWorldNodeModel.kt` | The node: ports, settings form and the `execute()` logic. | +| `resources/…/node/HelloWorldNodeModel.doc.md` | The help page the Workbench shows next to the node. The path must match the class's package and name exactly. | +| `test/…/HelloWorldNodeModelTest.kt` | Unit test. Runs without Spring, Kafka or Docker. | + +### Files that connect your nodes to the platform + +If you get one of these wrong, the build still passes but **the worker starts with no nodes**. These are the most common reasons a new node doesn't appear. + +| File | Why it matters | +|------|----------------| +| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. | +| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. | +| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | +| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | + +### Files that must agree with each other + +| Setting | Where it lives | Rule | +|---------|----------------|------| +| **Task queue** | `worker/src/main/resources/application.yaml` and `taskQueue` in `charts/*/values.yaml` | Must be **unique across all workers** and identical in both files. Two workers on one queue means Temporal can hand a node to a worker that doesn't have it. | +| **`featureVersion`** | `gradle.properties` and `appVersion` in `charts/*/Chart.yaml` | Must be equal. CI fails otherwise. | +| **`continuumPlatformVersion`** | `gradle.properties` only | Every module reads it with `property(...)`. Never hardcode it in a build file. | +| **Module list** | `settings.gradle.kts`, `worker/build.gradle.kts` and `.github/workflows/on-release.yml` + `build-module.yml` | Add or rename a module in all four. | + +### Files you can ignore + +- `docker/`: the local stack from Step 1. It has nothing of yours in it. +- `gradlew`, `gradle/`: the Gradle wrapper. +- `App.kt`: three lines that start Spring Boot. +- `charts/…/templates/`: Helm templates. You only touch them to rename (Step 3). + +## What the Gradle plugins do for you + +You don't declare Spring, Temporal, Jackson or test dependencies. The two Continuum plugins add them: + +| Plugin | Used in | Gives you | +|--------|---------|-----------| +| `org.projectcontinuum.feature` | feature modules | Kotlin, Spring dependency management, `continuum-commons`, test libraries, and the `validateContinuumNodeAnnotations` check that fails the build if a node lacks `@ContinuumNode`. | +| `org.projectcontinuum.feature-java` | Java feature modules | The same, for Java. | +| `org.projectcontinuum.worker` | `worker/` | Spring Boot, the worker starter (Temporal polling and node registration), `bootRun`, and Jib for the container image. | + +Add a `dependencies { }` block to a feature module only when your node needs an extra library. + +:::info[Versions] +The template builds against Continuum platform `0.0.20` (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Everything comes from Maven Central, so you don't need a GitHub token. +::: + +Next: [rename the template](./step-3-make-it-yours.md). diff --git a/docs/contributing/create-new-nodes/step-3-make-it-yours.md b/docs/contributing/create-new-nodes/step-3-make-it-yours.md new file mode 100644 index 0000000..e46fbfd --- /dev/null +++ b/docs/contributing/create-new-nodes/step-3-make-it-yours.md @@ -0,0 +1,110 @@ +--- +sidebar_position: 4 +sidebar_label: "3. Make it yours" +title: "Step 3: Make it yours" +--- + +# Step 3: Make it yours + + + Step 3 of 6 + About 20 minutes + + +The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. + +The examples below use these placeholders. Pick your values first: + +| Placeholder | Example | Used for | +|-------------|---------|----------| +| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | +| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | +| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique.** | + +## Checklist + +### 1. Project identity + +- [ ] `settings.gradle.kts`: set `rootProject.name = ""`. +- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. + +### 2. The feature module + +Rename the folder `features/continuum-feature-hello/` to `features//` and then: + +- [ ] `settings.gradle.kts`: change `include(":features:continuum-feature-hello")` to `include(":features:")`. +- [ ] `features//build.gradle.kts`: change `group` and `description`. +- [ ] Rename the package folders under `src/main/kotlin`, `src/test/kotlin` and `src/main/resources`, from `org/projectcontinuum/feature/example` to your `` path. Update the `package` line in every file you moved. +- [ ] `AutoConfigure.kt`: update the `basePackages` value in `@ComponentScan` to ``. +- [ ] `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`: change the line to `.AutoConfigure`. + +:::tip[Use your IDE's rename] +In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit the three text files above by hand: `AutoConfigure.kt`'s `basePackages`, the `.imports` file and the Gradle files. +::: + +### 3. Java example (optional) + +- [ ] If you only write Kotlin, delete `features/continuum-feature-hello-java/` and remove its `include(...)` from `settings.gradle.kts`, its `implementation(project(...))` from `worker/build.gradle.kts`, and its `id("org.projectcontinuum.feature-java")` line from `settings.gradle.kts`. +- [ ] If you keep it, repeat step 2 for it. + +### 4. The worker + +- [ ] `worker/build.gradle.kts`: + - `implementation(project(":features:"))` must point at your renamed module. + - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. + - Change `group` and `description`. +- [ ] `worker/src/main/resources/application.yaml`: + - `spring.application.name` → `-worker` + - the default of `node-task-queue` → `` + - the `org.projectcontinuum.feature.example` log level → `` + +:::danger[Pick a unique task queue now] +Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. +::: + +### 5. The Helm chart + +The chart folder, its helper templates and its values keys all carry the template's name. Replace them together or Helm will fail with "template not found". + +- [ ] Rename `charts/continuum-feature-template/` to `charts//`. +- [ ] `Chart.yaml`: change `name`, `description` and `home`. +- [ ] `values.yaml` and `values-dev.yaml`: + - the `featureTemplate:` key → a name for your worker (for example `featureDemo:`) + - `image.repository` → your image from `jibToImage` + - `taskQueue` → `` (**the same value as in `application.yaml`**) +- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with your new values key, and the `feature-template` component label with your own. +- [ ] `Chart.yaml` `appVersion` must equal `featureVersion` in `gradle.properties` (both `0.0.1` as shipped). + +### 6. CI and release workflows + +- [ ] `.github/workflows/on-release.yml`: update the `module:` entries in the matrix to your module names. +- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module names. + +### 7. Text files + +- [ ] `README.md` and `CONTRIBUTING.md`: replace the template's name, badges and links. + +## Check for leftovers + +Run this from the repository root. It should print nothing when you're done: + +```bash +grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ + --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . +``` + +If you kept the Java example or its folder name, `feature-hello` will still match; that's fine. Anything else is a missed rename. + +Then confirm nothing broke: + +```bash +./gradlew build +``` + +If you changed the chart, also run `helm lint charts/`. + +:::info[What you can skip for now] +You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. +::: + +Next: [write your node](./step-4-write-your-node.md). diff --git a/docs/contributing/create-new-nodes/step-3-write-the-node.md b/docs/contributing/create-new-nodes/step-3-write-the-node.md deleted file mode 100644 index 6a2f9b0..0000000 --- a/docs/contributing/create-new-nodes/step-3-write-the-node.md +++ /dev/null @@ -1,179 +0,0 @@ ---- -sidebar_position: 4 -sidebar_label: "3. Write the node" -title: "Step 3: Write the node" ---- - -# Step 3: Write the node - - - Step 3 of 9 - 33% through the guide - - -Put node classes in a `.node` subpackage. The platform derives your **feature ID** by removing the trailing `.node` segment from the class name. For example, `org.projectcontinuum.feature.demo.node.WordCounterNodeModel` gets the feature ID `org.projectcontinuum.feature.demo`. - -**`src/main/kotlin/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.kt`** - -```kotlin -package org.projectcontinuum.feature.demo.node - -import org.projectcontinuum.core.commons.annotation.ContinuumNode -import org.projectcontinuum.core.commons.exception.NodeRuntimeException -import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel -import org.projectcontinuum.core.commons.node.ProcessNodeModel -import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback -import org.projectcontinuum.core.commons.utils.NodeInputReader -import org.projectcontinuum.core.commons.utils.NodeOutputWriter -import org.slf4j.LoggerFactory -import org.springframework.http.MediaType.TEXT_PLAIN_VALUE -import tools.jackson.core.type.TypeReference -import tools.jackson.databind.ObjectMapper - -@ContinuumNode -class WordCounterNodeModel( - private val objectMapper: ObjectMapper -) : ProcessNodeModel() { - companion object { - private val LOGGER = LoggerFactory.getLogger(WordCounterNodeModel::class.java) - private val WHITESPACE = Regex("\\s+") - } - - // 1. Ports: the map keys ("data") are the port IDs used in execute() - final override val inputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "input table", contentType = TEXT_PLAIN_VALUE) - ) - final override val outputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "table with word counts", contentType = TEXT_PLAIN_VALUE) - ) - - // 2. Where the node appears in the workbench node explorer - override val categories = listOf("Demo") - - // 3. JSON Schema for the node's properties - val propertiesSchema: Map = objectMapper.readValue( - """ - { - "type": "object", - "properties": { - "inputCol": { "type": "string", "title": "Input Column" }, - "outputCol": { "type": "string", "title": "Output Column" }, - "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } - }, - "required": ["inputCol", "outputCol"] - } - """.trimIndent(), - object : TypeReference>() {} - ) - - // 4. JSON Forms UI schema: layout of the configuration dialog - val propertiesUiSchema: Map = objectMapper.readValue( - """ - { - "type": "VerticalLayout", - "elements": [ - { "type": "Control", "scope": "#/properties/inputCol" }, - { "type": "Control", "scope": "#/properties/outputCol" }, - { "type": "Control", "scope": "#/properties/minWordLength" } - ] - } - """.trimIndent(), - object : TypeReference>() {} - ) - - // 5. Metadata: what the workbench and registry see - override val metadata = ContinuumWorkflowModel.NodeData( - id = this.javaClass.name, - nodeModel = this.javaClass.name, - title = "Word Counter", - subTitle = "Count words per row", - description = "Counts the words in a text column and appends the count as a new column", - icon = """""", - inputs = inputPorts, - outputs = outputPorts, - properties = mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 1), - propertiesSchema = propertiesSchema, - propertiesUISchema = propertiesUiSchema - ) - - // 6. The node's logic - override fun execute( - properties: Map?, - inputs: Map, - nodeOutputWriter: NodeOutputWriter, - nodeProgressCallback: NodeProgressCallback - ) { - val inputCol = properties?.get("inputCol") as String? - ?: throw NodeRuntimeException(workflowId = "", nodeId = "", message = "inputCol is not provided") - val outputCol = properties["outputCol"] as String? - ?: throw NodeRuntimeException(workflowId = "", nodeId = "", message = "outputCol is not provided") - val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 - - val reader = inputs["data"] ?: throw NodeRuntimeException( - isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" - ) - val totalRows = reader.getRowCount() - - nodeOutputWriter.createOutputPortWriter("data").use { writer -> - reader.use { - var row = reader.read() - var rowNumber = 0L - while (row != null) { - val text = row[inputCol]?.toString() ?: "" - val count = text.trim().split(WHITESPACE).count { it.length >= minWordLength } - - writer.write(rowNumber, row.toMutableMap().apply { this[outputCol] = count }) - rowNumber++ - if (totalRows > 0) nodeProgressCallback.report((rowNumber * 100 / totalRows).toInt()) - row = reader.read() - } - LOGGER.info("Counted words in $rowNumber rows") - } - } - } -} -``` - -## The node contract - -| Rule | Why | -|------|-----| -| Annotate with `@ContinuumNode`, not `@Component`. | `@ContinuumNode` makes the bean prototype-scoped, so each execution gets a fresh instance. The build fails if a node class is missing it (see [Step 7](./step-7-build-and-test.md)). | -| Extend `ProcessNodeModel` for nodes with inputs, or `TriggerNodeModel` for source nodes. | `TriggerNodeModel` has only `outputPorts` and `execute(properties, nodeOutputWriter)`. | -| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The fully qualified class name is the node's identity in the registry and in saved workflows. Renaming or moving the class breaks existing workflows that use it. | -| Use Jackson 3 imports (`tools.jackson.*`). | Platform `0.0.20` is on Spring Boot 4 / Jackson 3. `com.fasterxml.jackson.databind` isn't on the classpath and won't compile. | -| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | - -## Properties and validation - -- `metadata.properties` holds the default values used when a node is dropped onto the canvas. -- Before `execute()` is called, `ProcessNodeModel.run()` **validates the configured properties against `propertiesSchema`**. Values that break `required`, `type`, `minimum` and similar rules fail the node before your code runs. You can still check values in `execute()` for clearer error messages. -- `propertiesUISchema` is a [JSON Forms](https://jsonforms.io/) UI schema, used only by the workbench to draw the configuration dialog. For credential pickers (`options.format = "credential"`), see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) before wiring them into a node. - -## Reading and writing rows - -- `inputs[portId]` is a `NodeInputReader`. `read()` returns the next row as `Map`, or `null` at the end of the table. `getRowCount()` returns the total number of rows. -- `nodeOutputWriter.createOutputPortWriter(portId)` returns a writer. `write(rowNumber, row)` takes a `Long` row index starting at `0`. -- Wrap both reader and writer in `.use { }`. The output Parquet file is only complete once the writer is closed. -- If an input port isn't connected, its key is missing from `inputs`. - -Cell values must be one of these types. Any other type makes `write()` throw `IllegalArgumentException: Unsupported type`. - -| Kotlin type | Stored as | -|-------------|-----------| -| `String` | `application/vnd.continuum.x-string` | -| `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | -| `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | -| `Boolean` | `application/vnd.continuum.x-boolean` | -| `List<*>`, `Map<*, *>` | `application/json` | -| SVG `org.w3c.dom.Document` | `image/svg+xml` | - -Convert anything else first, for example call `toString()` on a `LocalDate` or `BigDecimal`. A `null` value can't be stored either: leave the key out instead. - -## Errors and retries - -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors that a retry won't fix, such as missing configuration or a disconnected port. You can pass empty strings for `workflowId` and `nodeId`. The existing nodes do the same. - -## Progress - -Call `nodeProgressCallback.report(percent)` with a value from 0 to 100 as you go. The workbench uses it to show live progress on the node. diff --git a/docs/contributing/create-new-nodes/step-4-node-documentation.md b/docs/contributing/create-new-nodes/step-4-node-documentation.md deleted file mode 100644 index e06e3d8..0000000 --- a/docs/contributing/create-new-nodes/step-4-node-documentation.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -sidebar_position: 5 -sidebar_label: "4. Node documentation" -title: "Step 4: Add node documentation" ---- - -# Step 4: Add node documentation - - - Step 4 of 9 - 44% through the guide - - -Each node has a Markdown help page that the workbench shows next to it. It's loaded from the classpath on startup, at a path that matches the node's package and class name exactly: - -```text -src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md -``` - -If the file is missing, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. A good help page covers what the node does, its ports, a properties table, and a small input/output example. See the `.doc.md` files in [`continuum-feature-base`](https://github.com/projectcontinuum-org/continuum-feature-base) for the house style. diff --git a/docs/contributing/create-new-nodes/step-4-write-your-node.md b/docs/contributing/create-new-nodes/step-4-write-your-node.md new file mode 100644 index 0000000..37c4c4b --- /dev/null +++ b/docs/contributing/create-new-nodes/step-4-write-your-node.md @@ -0,0 +1,253 @@ +--- +sidebar_position: 5 +sidebar_label: "4. Write your node" +title: "Step 4: Write your node" +--- + +# Step 4: Write your node + + + Step 4 of 6 + About 30 minutes + + +You don't start from a blank file. Rename the template's **Hello World** node and change what it does. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. + +A node is three files that share a name. Do them in this order: + +1. [The node class](#1-the-node-class) +2. [The help page](#2-the-help-page) +3. [The unit test](#3-the-unit-test) + +## 1. The node class + +Rename `HelloWorldNodeModel.kt` to `WordCounterNodeModel.kt` (and the class inside it). The file has six parts. Only the numbered ones need your changes: + +```text +@ContinuumNode ← required, never remove +class WordCounterNodeModel(...) : ProcessNodeModel() { + 1. ports what goes in and out + 2. categories where it appears in the palette + 3. propertiesSchema what settings exist, and what is valid + 4. propertiesUiSchema how the settings form looks + 5. metadata name, description, icon, defaults + 6. execute() the logic +} +``` + +Here is the finished Word Counter, with the six parts marked: + +```kotlin +package org.projectcontinuum.feature.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.ProcessNodeModel +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE +import tools.jackson.core.type.TypeReference +import tools.jackson.databind.ObjectMapper + +@ContinuumNode +class WordCounterNodeModel( + private val objectMapper: ObjectMapper +) : ProcessNodeModel() { + + private val whitespace = Regex("\\s+") + + // 1. Ports. The map keys ("data") are the port IDs you use in execute(). + final override val inputPorts = mapOf( + "data" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + final override val outputPorts = mapOf( + "data" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + + // 2. Palette category + override val categories = listOf("Demo") + + // 3. JSON Schema: the settings and their rules + private val propertiesSchema: Map = objectMapper.readValue( + """ + { + "type": "object", + "properties": { + "inputCol": { "type": "string", "title": "Input Column" }, + "outputCol": { "type": "string", "title": "Output Column" }, + "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } + }, + "required": ["inputCol", "outputCol"] + } + """.trimIndent(), + object : TypeReference>() {} + ) + + // 4. JSON Forms UI schema: the layout of the settings form + private val propertiesUiSchema: Map = objectMapper.readValue( + """ + { + "type": "VerticalLayout", + "elements": [ + { "type": "Control", "scope": "#/properties/inputCol" }, + { "type": "Control", "scope": "#/properties/outputCol" }, + { "type": "Control", "scope": "#/properties/minWordLength" } + ] + } + """.trimIndent(), + object : TypeReference>() {} + ) + + // 5. Metadata: what the Workbench and the registry see + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "Word Counter", + subTitle = "Count words per row", + description = "Counts the words in a text column and appends the count as a new column", + icon = """""", + inputs = inputPorts, + outputs = outputPorts, + properties = mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 1), + propertiesSchema = propertiesSchema, + propertiesUISchema = propertiesUiSchema + ) + + // 6. The logic + override fun execute( + properties: Map?, + inputs: Map, + nodeOutputWriter: NodeOutputWriter, + nodeProgressCallback: NodeProgressCallback + ) { + val inputCol = properties?.get("inputCol") as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "inputCol is not provided") + val outputCol = properties["outputCol"] as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "outputCol is not provided") + val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 + + val reader = inputs["data"] ?: throw NodeRuntimeException( + isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" + ) + val totalRows = reader.getRowCount() + + nodeOutputWriter.createOutputPortWriter("data").use { writer -> + reader.use { + var rowNumber = 0L + while (true) { + val row = reader.read() ?: break + val text = row[inputCol]?.toString() ?: "" + val count = text.trim().split(whitespace).count { it.length >= minWordLength } + + writer.write(rowNumber, row.toMutableMap().apply { this[outputCol] = count }) + rowNumber++ + if (totalRows > 0) nodeProgressCallback.report((rowNumber * 100 / totalRows).toInt()) + } + } + } + } +} +``` + +### Rules the platform enforces + +Break one of these and the build fails, the node doesn't load, or workflows break later. + +| Rule | Why | +|------|-----| +| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. | +| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | +| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | +| Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | +| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.databind` won't compile. | +| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | + +### Settings and validation + +- `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. +- Before `execute()` runs, the platform checks the user's settings against `propertiesSchema`. Values that break `required`, `type` or `minimum` fail the node before your code starts. Checking again in `execute()` is still worthwhile because it lets you give a clearer error message. +- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. + +### Reading and writing rows + +- `inputs["data"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. +- `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. +- Wrap both in `.use { }`. The output file is only complete once the writer is closed. + +Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Convert other types first (for example `toString()` on a `LocalDate`), and leave a key out instead of storing `null`. + +| Kotlin type | Stored as | +|-------------|-----------| +| `String` | `application/vnd.continuum.x-string` | +| `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | +| `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | +| `Boolean` | `application/vnd.continuum.x-boolean` | +| `List<*>`, `Map<*, *>` | `application/json` | +| SVG `org.w3c.dom.Document` | `image/svg+xml` | + +### Errors, retries and progress + +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as missing settings or an unconnected port. Empty strings are fine for `workflowId` and `nodeId`. + +Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. + +## 2. The help page + +Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. + +The path must match the node's package and class name exactly: + +```text +src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md +``` + +If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. + +A good help page has four parts, as in the template's Hello World page: what the node does, a **Configuration** table, a **Ports** table, and a small **Example** with input and output tables. + +## 3. The unit test + +Rename `HelloWorldNodeModelTest.kt` to `WordCounterNodeModelTest.kt`. Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. + +```kotlin +class WordCounterNodeModelTest { + private val outputWriter = mock() + private val portWriter = mock() + private val node = WordCounterNodeModel(jacksonObjectMapper()) + + @BeforeEach + fun setUp() { + whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) + } + + @Test + fun `counts words and keeps original columns`() { + val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) + + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) + + val rows = argumentCaptor>() + verify(portWriter).write(any(), rows.capture()) + assertEquals(4, rows.firstValue["word_count"]) + assertEquals(1, rows.firstValue["id"]) + } + + private fun mockReader(rows: List>): NodeInputReader { + val iterator = rows.iterator() + return mock().also { r -> + whenever(r.read()).thenAnswer { if (iterator.hasNext()) iterator.next() else null } + whenever(r.getRowCount()).thenReturn(rows.size.toLong()) + } + } +} +``` + +The template's `HelloWorldNodeModelTest` has more cases to copy, including metadata checks and progress reporting. + +:::note +These tests call `execute()` directly, so they skip the schema validation. To test validation as well, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. +::: + +Next: [test and run your node](./step-5-test-and-run.md). diff --git a/docs/contributing/create-new-nodes/step-5-test-and-run.md b/docs/contributing/create-new-nodes/step-5-test-and-run.md new file mode 100644 index 0000000..92851c8 --- /dev/null +++ b/docs/contributing/create-new-nodes/step-5-test-and-run.md @@ -0,0 +1,63 @@ +--- +sidebar_position: 6 +sidebar_label: "5. Test and run" +title: "Step 5: Test and run your node" +--- + +# Step 5: Test and run your node + + + Step 5 of 6 + About 10 minutes + + +You ran the template unchanged in [Step 1](./step-1-clone-and-run.md). Now run it again with your changes. + +## 1. Build and test + +```bash +./gradlew build +``` + +This compiles every module, runs your unit tests, runs `validateContinuumNodeAnnotations` and builds the worker jar. To run one test class: + +```bash +./gradlew :features::test --tests "*WordCounterNodeModelTest" +``` + +:::note[The annotation check] +`validateContinuumNodeAnnotations` fails the build when a class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. If you see it fail, that's the cause. +::: + +## 2. Run the worker + +Make sure the local stack from Step 1 is still up (`docker compose ps` in `docker/`), then: + +```bash +./gradlew :worker:bootRun +``` + +## 3. Check the node was loaded + +Ask the worker which nodes it serves: + +```bash +curl http://localhost:8090/api/v1/node-repo +``` + +Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. The usual causes are, in order: + +1. The `.imports` file names the wrong class, or `AutoConfigure`'s `basePackages` doesn't cover your package ([Step 3](./step-3-make-it-yours.md#2-the-feature-module)). +2. `worker/build.gradle.kts` doesn't list your module. +3. The class is missing `@ContinuumNode`. + +## 4. Run it in the Workbench + +1. Open [http://localhost:3002](http://localhost:3002). **Word Counter** appears under **Demo**. +2. Add a table source that has a `text` column, such as **Create Table**, and connect it to Word Counter. +3. Open the Word Counter settings to see the form you defined, then run the workflow. +4. Click the output port. Every row has a new `word_count` column. + +You've now changed the template into your own working worker. + +Next: [ship it](./step-6-ship-it.md). diff --git a/docs/contributing/create-new-nodes/step-5-unit-tests.md b/docs/contributing/create-new-nodes/step-5-unit-tests.md deleted file mode 100644 index fac9946..0000000 --- a/docs/contributing/create-new-nodes/step-5-unit-tests.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -sidebar_position: 6 -sidebar_label: "5. Unit tests" -title: "Step 5: Write unit tests" ---- - -# Step 5: Write unit tests - - - Step 5 of 9 - 56% through the guide - - -`execute()` only depends on its arguments, so you can test it with Mockito mocks and no Spring context: - -**`src/test/kotlin/org/projectcontinuum/feature/demo/node/WordCounterNodeModelTest.kt`** - -```kotlin -class WordCounterNodeModelTest { - private val outputWriter = mock() - private val portWriter = mock() - private val node = WordCounterNodeModel(jacksonObjectMapper()) - - @BeforeEach - fun setUp() { - whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) - } - - @Test - fun `counts words and preserves original columns`() { - val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) - - node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) - - val rows = argumentCaptor>() - verify(portWriter).write(any(), rows.capture()) - assertEquals(4, rows.firstValue["word_count"]) - assertEquals(1, rows.firstValue["id"]) - } - - private fun mockReader(rows: List>): NodeInputReader { - val iterator = rows.iterator() - return mock().also { r -> - whenever(r.read()).thenAnswer { if (iterator.hasNext()) iterator.next() else null } - whenever(r.getRowCount()).thenReturn(rows.size.toLong()) - } - } -} -``` - -The imports come from `org.junit.jupiter.api`, `org.mockito.kotlin`, `kotlin.test` and `tools.jackson.module.kotlin.jacksonObjectMapper`. The feature plugin already adds all of them as test dependencies. - -These tests call `execute()` directly, so they skip the schema validation step. To test validation too, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. diff --git a/docs/contributing/create-new-nodes/step-6-ship-it.md b/docs/contributing/create-new-nodes/step-6-ship-it.md new file mode 100644 index 0000000..94bfff7 --- /dev/null +++ b/docs/contributing/create-new-nodes/step-6-ship-it.md @@ -0,0 +1,91 @@ +--- +sidebar_position: 7 +sidebar_label: "6. Ship it" +title: "Step 6: Ship it" +--- + +# Step 6: Ship it + + + Step 6 of 6 + Needs repository secrets + + +Shipping is mostly already set up in the template. This page explains what each piece does and what you need to provide. + +## The release flow + +```mermaid +flowchart TB + A["Bump featureVersion"] --> B["Open PR: CI checks run"] --> D["Merge to main"] --> E["Publish a GitHub release"] + E --> F["Feature modules to Maven Central
on-release.yml"] + E --> G["Worker image to Docker Hub
on-release.yml"] + E --> H["Helm chart to gh-pages
release.yml"] +``` + +## 1. Bump the version + +Every change under `features/` or `worker/` needs a new `featureVersion` in `gradle.properties`, and the chart's `appVersion` in `charts//Chart.yaml` must be set to the same value. + +CI enforces both on every pull request (`validate-versions.yml`). If your PR fails with "does not match featureVersion" or "featureVersion must be bumped", this is why. + +## 2. What CI runs + +| Workflow | When | What it does | +|----------|------|--------------| +| `ci.yml` | PR, push to `main` | `./gradlew build` | +| `validate-versions.yml` | PR | Checks the version rules above | +| `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | +| `build-module.yml` | Manual | Build one module, optionally publish it | +| `on-release.yml` | GitHub release | Libraries → Maven Central, worker → Docker Hub | +| `release.yml` | GitHub release | Package the Helm chart and update the `gh-pages` index | + +## 3. Add repository secrets + +The release workflows read these from your repository's **Settings → Secrets and variables → Actions**: + +| Secret | Used for | +|--------|----------| +| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | +| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | + +:::tip[Not publishing libraries?] +If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. +::: + +## 4. Deploy to Kubernetes + +The chart installs next to `continuum-infra` and `continuum-platform` in the same namespace: + +```bash +helm install ./charts/ -n continuum +``` + +Check these before you install: + +- `taskQueue` in `values.yaml` matches `node-task-queue` in `application.yaml`, and is unique. +- `image.repository` is the image your release pushes. +- The `continuum.infra.*` and `apiServer` hosts match the release names you used for `continuum-infra` and `continuum-platform`. + +See [Deployment](../../deployment/helm-charts.md) for the full setup. + +## Worker configuration reference + +You don't need to set Kafka, MinIO or the API server addresses; the worker starter ships defaults that match the local stack. Override them with environment variables when you deploy elsewhere: + +| Variable | Default | Purpose | +|----------|---------|---------| +| `CONTINUUM_NODE_TASK_QUEUE` | from `application.yaml` | This worker's Temporal task queue | +| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend | +| `TEMPORAL_NAMESPACE` | `default` | Temporal namespace | +| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | Where nodes register | +| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,localhost:39093,localhost:39094` | Kafka brokers | +| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Schema registry | +| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage for node data | +| `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` | MinIO credentials | +| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()` | +| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local scratch folder | +| `SERVER_PORT` | `8090` | Worker HTTP port (8080 belongs to the API server) | + +You're done. Your worker is live and its nodes are available in the Workbench. diff --git a/docs/contributing/create-new-nodes/step-6-worker-module.md b/docs/contributing/create-new-nodes/step-6-worker-module.md deleted file mode 100644 index 48343e7..0000000 --- a/docs/contributing/create-new-nodes/step-6-worker-module.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -sidebar_position: 7 -sidebar_label: "6. Worker module" -title: "Step 6: Create the worker module" ---- - -# Step 6: Create the worker module - - - Step 6 of 9 - 67% through the guide - - -**`worker/build.gradle.kts`** - -```kotlin -plugins { - id("org.projectcontinuum.worker") -} - -group = "org.projectcontinuum.app.worker.demo" -description = "Continuum Feature Demo Worker" -version = property("featureVersion").toString() - -continuum { - continuumVersion.set(property("continuumPlatformVersion").toString()) - // Optional: set this to build a container image with `./gradlew :worker:jib` - // jibToImage.set("docker.io/your-org/continuum-feature-demo:${version}") -} - -dependencies { - implementation(project(":features:continuum-feature-demo")) -} -``` - -**`worker/src/main/kotlin/org/projectcontinuum/app/worker/demo/App.kt`** - -```kotlin -package org.projectcontinuum.app.worker.demo - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -class App - -fun main(args: Array) { - runApplication(*args) -} -``` - -**`worker/src/main/resources/application.yaml`** - -```yaml -spring.application.name: continuum-feature-demo-worker - -# The worker runs a web server. Its default port 8080 clashes with -# continuum-api-server in the local stack. -server.port: ${SERVER_PORT:8090} - -spring: - temporal: - namespace: ${TEMPORAL_NAMESPACE:default} - connection: - target: ${TEMPORAL_SERVER_ADDRESS:localhost:7233} - workersAutoDiscovery: - packages: - - org.projectcontinuum.core.worker.starter - -continuum.core: - worker: - # Every worker needs its OWN task queue (see the warning below). - node-task-queue: ${CONTINUUM_NODE_TASK_QUEUE:CONTINUUM_FEATURE_DEMO_TASK_QUEUE} - -logging: - level: - root: error - org.projectcontinuum.core.worker: info - org.projectcontinuum.feature.demo: debug -``` - -:::danger[Give every worker a unique task queue] -If `node-task-queue` isn't set, a worker listens on the shared default queue `ACTIVITY_TASK_QUEUE`. When two workers share a queue, Temporal can send a node to a worker that doesn't have it, and the node fails. Every shipped worker sets its own queue (for example `CONTINUUM_FEATURE_BASE_TASK_QUEUE`), and yours must too. The worker sends its queue name in its registration message, so the orchestrator knows where to route your nodes. -::: - -## Environment variables - -You don't need to configure Kafka, MinIO, the API server or the credentials server here. `continuum-worker-springboot-starter` ships defaults that point at the [local stack](../../getting-started/local-setup.md) ports, and each one can be overridden with an environment variable: - -| Variable | Default | Purpose | -|----------|---------|---------| -| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend | -| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,localhost:39093,localhost:39094` | Kafka brokers for node registration | -| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Avro schema registry | -| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object store for Parquet inputs and outputs | -| `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` / `minioadmin` | MinIO credentials | -| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | API server | -| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only used by nodes that call `getCredential()` | -| `CONTINUUM_NODE_TASK_QUEUE` | none (falls back to `ACTIVITY_TASK_QUEUE`) | This worker's Temporal task queue | -| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local staging folder for Parquet files | diff --git a/docs/contributing/create-new-nodes/step-7-build-and-test.md b/docs/contributing/create-new-nodes/step-7-build-and-test.md deleted file mode 100644 index 664368f..0000000 --- a/docs/contributing/create-new-nodes/step-7-build-and-test.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -sidebar_position: 8 -sidebar_label: "7. Build and test" -title: "Step 7: Build and test" ---- - -# Step 7: Build and test - - - Step 7 of 9 - 78% through the guide - - -```bash -./gradlew build -``` - -This compiles every module, runs `validateContinuumNodeAnnotations`, runs the unit tests and builds `worker/build/libs/worker-.jar`. - -To check that the annotation guard works, swap `@ContinuumNode` for `@Component` and run `./gradlew classes`. The build fails with: - -```text -> Task :features:continuum-feature-demo:validateContinuumNodeAnnotations FAILED - Continuum Node Annotation Validation Failed - The following classes implement ContinuumNodeModel but are missing the @ContinuumNode annotation: -``` diff --git a/docs/contributing/create-new-nodes/step-8-run-locally.md b/docs/contributing/create-new-nodes/step-8-run-locally.md deleted file mode 100644 index 6682dc3..0000000 --- a/docs/contributing/create-new-nodes/step-8-run-locally.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -sidebar_position: 9 -sidebar_label: "8. Run locally" -title: "Step 8: Run the worker against the local stack" ---- - -# Step 8: Run the worker against the local stack - - - Step 8 of 9 - 89% through the guide - - -1. Start the platform with the [Local Setup](../../getting-started/local-setup.md) compose file and wait until every service is healthy. -2. Start your worker: - - ```bash - ./gradlew :worker:bootRun - ``` - -3. Check that the worker loaded your node. This endpoint returns the node tree that the worker serves: - - ```bash - curl http://localhost:8090/api/v1/node-repo - ``` - -4. Open the [workbench](http://127.0.0.1:3002). **Word Counter** appears under the **Demo** category. Drop it onto the canvas after a node that outputs a `text` column, such as **Create Table**, and run the workflow. diff --git a/docs/contributing/create-new-nodes/step-9-ship-it.md b/docs/contributing/create-new-nodes/step-9-ship-it.md deleted file mode 100644 index 6e4ceba..0000000 --- a/docs/contributing/create-new-nodes/step-9-ship-it.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -sidebar_position: 10 -sidebar_label: "9. Ship it" -title: "Step 9: Ship it" ---- - -# Step 9: Ship it - - - Step 9 of 9 - 100% through the guide - - -- **Container image:** set `jibToImage` in `worker/build.gradle.kts` and run `./gradlew :worker:jib`. Jib reads registry credentials from `DOCKER_REPO_USERNAME` / `DOCKER_REPO_PASSWORD`. The base image defaults to `eclipse-temurin:21-jre` and can be changed with `jibFromImage`. -- **Kubernetes:** deploy the worker as its own release in the platform's namespace and set the [environment variables](./step-6-worker-module.md#environment-variables) from Step 6, including a unique `CONTINUUM_NODE_TASK_QUEUE`. The charts in the existing feature repos (for example `continuum-feature-base/charts/`) are a working reference. See [Deployment](../../deployment/helm-charts.md). -- **Publishing feature modules:** the plugins configure Maven Central publishing through JReleaser by default. If you don't publish libraries, set `publishToMavenCentral.set(false)` in the `continuum { }` block. diff --git a/docs/contributing/create-new-nodes/troubleshooting.md b/docs/contributing/create-new-nodes/troubleshooting.md index c714d8e..c9bad42 100644 --- a/docs/contributing/create-new-nodes/troubleshooting.md +++ b/docs/contributing/create-new-nodes/troubleshooting.md @@ -1,18 +1,31 @@ --- -sidebar_position: 11 +sidebar_position: 8 sidebar_label: Troubleshooting title: Troubleshooting --- # Troubleshooting +## My node doesn't show up in the Workbench + +Work down this list. Each item is a more common cause than the next. + +1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the problem is on the Workbench or platform side; refresh the page and check the local stack is healthy. +2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`. +3. **Does Spring find the module?** The `.imports` file must contain the full name of your `AutoConfigure` class, and `AutoConfigure`'s `@ComponentScan(basePackages = ...)` must cover your node's package. See [Step 3](./step-3-make-it-yours.md#2-the-feature-module). +4. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. + +## Errors + | Symptom | Cause and fix | |---------|---------------| -| `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | That version isn't on Maven Central (for example an old `-SNAPSHOT`), or `mavenCentral()` is missing from `pluginManagement.repositories`. Use a released `continuumPlatformVersion`. See [Step 1](./step-1-root-project.md). | -| `Unresolved reference 'databind'` / `'ObjectMapper'` | You're using Jackson 2 imports (`com.fasterxml.jackson.*`). Switch to `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | +| `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | +| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | -| Worker starts but your node isn't listed | The `AutoConfiguration.imports` file is missing or points at the wrong class, or the node is outside the `AutoConfigure` package. See [Step 2](./step-2-feature-module.md#register-the-module-with-spring). | -| `Port 8080 was already in use` on `bootRun` | The local API server already uses 8080. Set `server.port` (see [Step 6](./step-6-worker-module.md)). | -| Node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `CONTINUUM_NODE_TASK_QUEUE`. | -| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't one of the [supported types](./step-3-write-the-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-node-documentation.md). | +| `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | +| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | +| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | +| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows. | diff --git a/docs/contributing/feature-template.md b/docs/contributing/feature-template.md index 6a8239b..244b8db 100644 --- a/docs/contributing/feature-template.md +++ b/docs/contributing/feature-template.md @@ -11,7 +11,7 @@ Continuum is designed to be extended by **adding new workers**, not modifying ex To build your own set of nodes, start from [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) — a scaffold for a standalone Gradle project with the Spring Boot worker setup, Temporal registration, and `@ContinuumNode` conventions already wired up. :::tip -The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. Its README covers renaming it for your own feature. For a walkthrough of writing a node from scratch, see [Create New Nodes](./create-new-nodes/overview.md). +The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it and writing your first node, see [Create New Nodes](./create-new-nodes/overview.md). ::: Once your worker is running and registering nodes, it can be deployed as an independent release into the same Kubernetes namespace as the core platform (see [Deployment](../deployment/helm-charts.md)) — no changes to `continuum-platform-core` or any other feature repo required. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md index 7c53887..00cfffd 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md @@ -7,62 +7,58 @@ slug: /contributing/create-new-nodes # Create New Nodes -This guide walks you through building a **feature worker** with your own workflow node, from an empty folder to a passing build and a worker that registers its node with the platform. The running example is a **Word Counter** node that counts the words in a text column and appends the count as a new column. + + +Start from the **`continuum-feature-template`** repository, rename it, replace its example node with yours, and ship a worker. You write one Kotlin or Java class per node. The template provides everything else. + + - Kotlin + Gradle - 9 steps + Kotlin or Java + 6 steps Platform 0.0.20 -You need to know some Kotlin and Gradle. You don't need to know Temporal, Kafka or Spring internals; the Continuum Gradle plugins and the worker starter handle those. +## The idea in one minute -:::info[Versions used in this guide] -Verified against **Continuum platform `0.0.20`** (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Check [Maven Central](https://central.sonatype.com/artifact/org.projectcontinuum.core/continuum-commons) for the latest platform version, and use the same version everywhere in your project. -::: +A **node** is a block on the Workbench canvas that reads tables, does something and writes tables. Nodes live in a **feature worker**, a small Spring Boot app that registers its nodes with the platform at startup. -## How the pieces fit +You don't build a worker from scratch. The template is already a complete, working worker with two example nodes, a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. -A feature worker is a small Gradle multi-project: - -``` -continuum-feature-demo/ -├── settings.gradle.kts # plugin versions + module list -├── gradle.properties # continuumPlatformVersion, featureVersion -├── features/ -│ └── continuum-feature-demo/ # library module: your node classes -└── worker/ # thin Spring Boot app that hosts the nodes +```mermaid +flowchart LR + S1["1
Clone and run"] --> S2["2
Tour"] --> S3["3
Rename"] --> S4["4
Write your node"] --> S5["5
Test and run"] --> S6["6
Ship"] ``` -- **Feature modules** (`org.projectcontinuum.feature` plugin) hold the node classes. They're plain libraries and can be published and reused. -- **The worker module** (`org.projectcontinuum.worker` plugin) is a Spring Boot app with no node logic of its own. It depends on your feature modules and on `continuum-worker-springboot-starter`. At startup the starter finds every `@ContinuumNode` bean, polls a Temporal task queue for node executions, and publishes one registration message per node to Kafka. - -See [Node Model & Feature Registration](../../architecture/node-model.md) for what happens after registration. - -## Prerequisites +## What you need | Requirement | Notes | |-------------|-------| -| JDK 21 | Eclipse Temurin recommended. The plugins set a Java 21 toolchain. | -| Gradle wrapper 8.14+ | Older wrappers (for example 8.4) can't load the Spring Boot 4 Gradle plugin. | -| Docker | Only needed to run the worker against the [local stack](../../getting-started/local-setup.md). | +| JDK 21 | Eclipse Temurin recommended. | +| Docker and Compose | Runs the local Continuum stack, about 8 GB of RAM. | +| Some Kotlin or Java | You don't need to know Temporal, Kafka or Spring internals. | -You **don't** need a GitHub token. All Continuum artifacts and Gradle plugins are published to **Maven Central**. +You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. ## The steps -1. [Create the root project](./step-1-root-project.md) -2. [Create the feature module](./step-2-feature-module.md) -3. [Write the node](./step-3-write-the-node.md) -4. [Add node documentation](./step-4-node-documentation.md) -5. [Write unit tests](./step-5-unit-tests.md) -6. [Create the worker module](./step-6-worker-module.md) -7. [Build and test](./step-7-build-and-test.md) -8. [Run the worker against the local stack](./step-8-run-locally.md) -9. [Ship it](./step-9-ship-it.md) +1. [Clone the template and run it](./step-1-clone-and-run.md): see the example nodes working before you change anything. +2. [Tour the template](./step-2-tour-the-template.md): which files you write, which you rename and which you leave alone. +3. [Make it yours](./step-3-make-it-yours.md): a checklist for renaming the project, packages, worker and chart. +4. [Write your node](./step-4-write-your-node.md): the node class, its help page and its unit test. +5. [Test and run your node](./step-5-test-and-run.md): build, run the worker and use your node in the Workbench. +6. [Ship it](./step-6-ship-it.md): versions, CI, release and Kubernetes. -If something goes wrong along the way, see [Troubleshooting](./troubleshooting.md). +## Where to look when something breaks + +- Your node doesn't appear in the Workbench: [Troubleshooting](./troubleshooting.md). +- The platform's side of registration: [Node Model & Feature Registration](../../architecture/node-model.md). +- The template's own README and `AGENTS.md` list its commands and rules. + +:::info[Versions] +Verified against **Continuum platform `0.0.20`** (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Check [Maven Central](https://central.sonatype.com/artifact/org.projectcontinuum.core/continuum-commons) for newer versions. +::: diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md new file mode 100644 index 0000000..1bb1f20 --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md @@ -0,0 +1,75 @@ +--- +sidebar_position: 2 +sidebar_label: "1. Clone and run" +title: "Step 1: Clone the template and run it" +--- + +# Step 1: Clone the template and run it + + + Step 1 of 6 + About 10 minutes + + +Before you change anything, get the unmodified template running. You'll see the two example nodes on a canvas, and from then on you know that any breakage comes from your own changes. + +## 1. Get the code + +On GitHub, open [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) and click **Use this template**. That creates a copy in your own organisation without the template's git history. Then clone your copy: + +```bash +git clone https://github.com//.git +cd +``` + +## 2. Build it + +```bash +./gradlew build +``` + +This compiles both example modules, runs their unit tests, checks that every node is annotated correctly and packages the worker jar. The Gradle wrapper is already in the repo; you only need JDK 21. + +## 3. Start the local Continuum stack + +```bash +cd docker +docker compose up -d +``` + +Wait until `docker compose ps` shows the services as healthy. The `temporal-search-attributes-init` container exits when its setup is done; that's expected. The stack needs about 8 GB of RAM. + +## 4. Start your worker + +From the repository root: + +```bash +./gradlew :worker:bootRun +``` + +The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. + +## 5. See your nodes in the Workbench + +1. Open the Workbench at [http://localhost:3002](http://localhost:3002). +2. In the node palette, find **Hello World** and **Hello Java** under **Examples**. +3. Drag a table source onto the canvas (for example **Create Table**), connect it to **Hello World**, and run the workflow. + +Each row gets a new `greeting` column. + +:::tip[It worked if you see the nodes] +If the palette is empty, the worker didn't register. Check [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health) and see [Troubleshooting](./troubleshooting.md). +::: + +## Local endpoints + +| Service | URL | +|---------|-----| +| Workbench | [http://localhost:3002](http://localhost:3002) | +| API server | [http://localhost:8080](http://localhost:8080) | +| Your worker | [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health) | +| Temporal UI | [http://localhost:38081](http://localhost:38081) | +| Kafka UI | [http://localhost:38082](http://localhost:38082) | +| MinIO console | [http://localhost:39001](http://localhost:39001) (`minioadmin` / `minioadmin`) | + +Next: [take a tour of what you just ran](./step-2-tour-the-template.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-root-project.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-root-project.md deleted file mode 100644 index 084424a..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-root-project.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -sidebar_position: 2 -sidebar_label: "1. Root project" -title: "Step 1: Create the root project" ---- - -# Step 1: Create the root project - - - Step 1 of 9 - 11% through the guide - - -Create the folder and add a Gradle wrapper. If Gradle is installed, run `gradle wrapper --gradle-version 8.14`. Otherwise, copy `gradlew`, `gradlew.bat` and `gradle/wrapper/` from an existing feature repo such as `continuum-feature-base`. - -**`gradle.properties`** - -```properties -repoName=your-org/continuum-feature-demo -continuumPlatformVersion=0.0.20 -featureVersion=0.0.1 - -# Spring Boot 4 pulls in a large Kotlin compiler jar; give the Gradle daemon enough heap. -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -``` - -- `continuumPlatformVersion` selects the Gradle plugin version and the `continuum-commons` / `continuum-worker-springboot-starter` versions. -- `featureVersion` is your own version. -- `repoName` is used in published POM metadata and in the default container image name. - -**`settings.gradle.kts`** - -```kotlin -pluginManagement { - val continuumPlatformVersion: String by settings - repositories { - mavenLocal() - mavenCentral() - gradlePluginPortal() - } - plugins { - id("org.projectcontinuum.feature") version continuumPlatformVersion - id("org.projectcontinuum.worker") version continuumPlatformVersion - } -} - -rootProject.name = "continuum-feature-demo" - -include(":features:continuum-feature-demo") -include(":worker") -``` - -The plugins are resolved from Maven Central, so `mavenCentral()` must be in `pluginManagement.repositories`, not only in `gradlePluginPortal()`. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-feature-module.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-feature-module.md deleted file mode 100644 index 77d01b7..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-feature-module.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -sidebar_position: 3 -sidebar_label: "2. Feature module" -title: "Step 2: Create the feature module" ---- - -# Step 2: Create the feature module - - - Step 2 of 9 - 22% through the guide - - -**`features/continuum-feature-demo/build.gradle.kts`** - -```kotlin -plugins { - id("org.projectcontinuum.feature") -} - -group = "org.projectcontinuum.feature.demo" -description = "Continuum Feature Demo — demo nodes" -version = property("featureVersion").toString() - -continuum { - continuumVersion.set(property("continuumPlatformVersion").toString()) -} -``` - -:::warning[Always set `continuumVersion`] -If you leave out the `continuum { }` block, the plugin falls back to a built-in default version that is older than the plugin itself. Read the value from `gradle.properties` so plugins and libraries always match. -::: - -The `org.projectcontinuum.feature` plugin applies Kotlin and Spring dependency management and adds these dependencies for you, so you don't declare them yourself: - -- Spring Boot starter, web, actuator and autoconfigure -- `continuum-commons` -- `kotlin-reflect` and `tools.jackson.module:jackson-module-kotlin` -- Test: `spring-boot-starter-test`, `kotlin-test-junit5`, `mockito-kotlin` - -It also registers the `validateContinuumNodeAnnotations` task, which runs before `classes`. Add a `dependencies { }` block only for extra libraries your nodes need. - -## Register the module with Spring - -The worker finds your nodes through Spring Boot auto-configuration, so each feature module needs two small files. - -**`src/main/kotlin/org/projectcontinuum/feature/demo/AutoConfigure.kt`** - -```kotlin -package org.projectcontinuum.feature.demo - -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.Configuration - -@Configuration -@ComponentScan -class AutoConfigure -``` - -**`src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`** - -```text -org.projectcontinuum.feature.demo.AutoConfigure -``` - -`@ComponentScan` with no arguments scans the package of `AutoConfigure` and its subpackages. If the imports file is missing or names the wrong class, the build still passes but the worker starts with none of your nodes. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md new file mode 100644 index 0000000..83a3b07 --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md @@ -0,0 +1,127 @@ +--- +sidebar_position: 3 +sidebar_label: "2. Tour the template" +title: "Step 2: Tour the template" +--- + +# Step 2: Tour the template + + + Step 2 of 6 + About 5 minutes + + +The template has about 40 files, but you will only write code in a handful of them. This page shows which ones, and why the rest exist. + +## The big picture + +Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. + +```mermaid +flowchart LR + W["worker/
The app you run and deploy.
No node logic."] + W -->|loads| K["features/continuum-feature-hello
Nodes in Kotlin"] + W -->|loads| J["features/continuum-feature-hello-java
Nodes in Java"] +``` + +At startup the worker finds every class annotated with `@ContinuumNode`, listens on its own Temporal task queue for work, and announces each node to the platform so it shows up in the Workbench palette. + +## Where things are + +Each file or folder below is tagged with what you need to do with it. + +| Tag | Meaning | +|-----|---------| +| **Write** | Your code goes here. You'll edit or add files. | +| **Rename once** | Contains the template's name. Change it in [Step 3](./step-3-make-it-yours.md), then forget about it. | +| **Keep in sync** | Several files must agree. If you change one, change the others. | +| **Leave alone** | Works as shipped. | + +```text +continuum-feature-template/ +├── gradle.properties Keep in sync platform + feature versions +├── settings.gradle.kts Rename once project name + list of modules +├── build.gradle.kts Leave alone +│ +├── features/ +│ └── continuum-feature-hello/ Rename once a feature module (Kotlin) +│ ├── build.gradle.kts Rename once group, description +│ └── src/ +│ ├── main/kotlin/…/example/ +│ │ ├── AutoConfigure.kt Rename once tells Spring where your nodes are +│ │ └── node/ +│ │ └── HelloWorldNodeModel.kt Write ← your node +│ ├── main/resources/ +│ │ ├── META-INF/spring/…AutoConfiguration.imports Rename once +│ │ └── …/node/HelloWorldNodeModel.doc.md Write ← help page +│ └── test/kotlin/…/HelloWorldNodeModelTest.kt Write ← unit test +│ +├── features/continuum-feature-hello-java/ Delete if you only write Kotlin (same layout) +│ +├── worker/ +│ ├── build.gradle.kts Keep in sync which modules the worker loads, image name +│ └── src/main/ +│ ├── kotlin/…/App.kt Leave alone Spring Boot entry point +│ └── resources/application.yaml Keep in sync task queue, app name +│ +├── charts/continuum-feature-template/ Keep in sync Helm chart for Kubernetes +├── docker/ Leave alone local Continuum stack +└── .github/workflows/ Keep in sync CI and release (lists your modules) +``` + +## The files that matter + +### Files you write + +These three live side by side in each feature module and share a name: + +| File | What it is | +|------|------------| +| `node/HelloWorldNodeModel.kt` | The node: ports, settings form and the `execute()` logic. | +| `resources/…/node/HelloWorldNodeModel.doc.md` | The help page the Workbench shows next to the node. The path must match the class's package and name exactly. | +| `test/…/HelloWorldNodeModelTest.kt` | Unit test. Runs without Spring, Kafka or Docker. | + +### Files that connect your nodes to the platform + +If you get one of these wrong, the build still passes but **the worker starts with no nodes**. These are the most common reasons a new node doesn't appear. + +| File | Why it matters | +|------|----------------| +| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. | +| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. | +| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | +| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | + +### Files that must agree with each other + +| Setting | Where it lives | Rule | +|---------|----------------|------| +| **Task queue** | `worker/src/main/resources/application.yaml` and `taskQueue` in `charts/*/values.yaml` | Must be **unique across all workers** and identical in both files. Two workers on one queue means Temporal can hand a node to a worker that doesn't have it. | +| **`featureVersion`** | `gradle.properties` and `appVersion` in `charts/*/Chart.yaml` | Must be equal. CI fails otherwise. | +| **`continuumPlatformVersion`** | `gradle.properties` only | Every module reads it with `property(...)`. Never hardcode it in a build file. | +| **Module list** | `settings.gradle.kts`, `worker/build.gradle.kts` and `.github/workflows/on-release.yml` + `build-module.yml` | Add or rename a module in all four. | + +### Files you can ignore + +- `docker/`: the local stack from Step 1. It has nothing of yours in it. +- `gradlew`, `gradle/`: the Gradle wrapper. +- `App.kt`: three lines that start Spring Boot. +- `charts/…/templates/`: Helm templates. You only touch them to rename (Step 3). + +## What the Gradle plugins do for you + +You don't declare Spring, Temporal, Jackson or test dependencies. The two Continuum plugins add them: + +| Plugin | Used in | Gives you | +|--------|---------|-----------| +| `org.projectcontinuum.feature` | feature modules | Kotlin, Spring dependency management, `continuum-commons`, test libraries, and the `validateContinuumNodeAnnotations` check that fails the build if a node lacks `@ContinuumNode`. | +| `org.projectcontinuum.feature-java` | Java feature modules | The same, for Java. | +| `org.projectcontinuum.worker` | `worker/` | Spring Boot, the worker starter (Temporal polling and node registration), `bootRun`, and Jib for the container image. | + +Add a `dependencies { }` block to a feature module only when your node needs an extra library. + +:::info[Versions] +The template builds against Continuum platform `0.0.20` (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Everything comes from Maven Central, so you don't need a GitHub token. +::: + +Next: [rename the template](./step-3-make-it-yours.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md new file mode 100644 index 0000000..e46fbfd --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md @@ -0,0 +1,110 @@ +--- +sidebar_position: 4 +sidebar_label: "3. Make it yours" +title: "Step 3: Make it yours" +--- + +# Step 3: Make it yours + + + Step 3 of 6 + About 20 minutes + + +The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. + +The examples below use these placeholders. Pick your values first: + +| Placeholder | Example | Used for | +|-------------|---------|----------| +| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | +| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | +| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique.** | + +## Checklist + +### 1. Project identity + +- [ ] `settings.gradle.kts`: set `rootProject.name = ""`. +- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. + +### 2. The feature module + +Rename the folder `features/continuum-feature-hello/` to `features//` and then: + +- [ ] `settings.gradle.kts`: change `include(":features:continuum-feature-hello")` to `include(":features:")`. +- [ ] `features//build.gradle.kts`: change `group` and `description`. +- [ ] Rename the package folders under `src/main/kotlin`, `src/test/kotlin` and `src/main/resources`, from `org/projectcontinuum/feature/example` to your `` path. Update the `package` line in every file you moved. +- [ ] `AutoConfigure.kt`: update the `basePackages` value in `@ComponentScan` to ``. +- [ ] `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`: change the line to `.AutoConfigure`. + +:::tip[Use your IDE's rename] +In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit the three text files above by hand: `AutoConfigure.kt`'s `basePackages`, the `.imports` file and the Gradle files. +::: + +### 3. Java example (optional) + +- [ ] If you only write Kotlin, delete `features/continuum-feature-hello-java/` and remove its `include(...)` from `settings.gradle.kts`, its `implementation(project(...))` from `worker/build.gradle.kts`, and its `id("org.projectcontinuum.feature-java")` line from `settings.gradle.kts`. +- [ ] If you keep it, repeat step 2 for it. + +### 4. The worker + +- [ ] `worker/build.gradle.kts`: + - `implementation(project(":features:"))` must point at your renamed module. + - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. + - Change `group` and `description`. +- [ ] `worker/src/main/resources/application.yaml`: + - `spring.application.name` → `-worker` + - the default of `node-task-queue` → `` + - the `org.projectcontinuum.feature.example` log level → `` + +:::danger[Pick a unique task queue now] +Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. +::: + +### 5. The Helm chart + +The chart folder, its helper templates and its values keys all carry the template's name. Replace them together or Helm will fail with "template not found". + +- [ ] Rename `charts/continuum-feature-template/` to `charts//`. +- [ ] `Chart.yaml`: change `name`, `description` and `home`. +- [ ] `values.yaml` and `values-dev.yaml`: + - the `featureTemplate:` key → a name for your worker (for example `featureDemo:`) + - `image.repository` → your image from `jibToImage` + - `taskQueue` → `` (**the same value as in `application.yaml`**) +- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with your new values key, and the `feature-template` component label with your own. +- [ ] `Chart.yaml` `appVersion` must equal `featureVersion` in `gradle.properties` (both `0.0.1` as shipped). + +### 6. CI and release workflows + +- [ ] `.github/workflows/on-release.yml`: update the `module:` entries in the matrix to your module names. +- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module names. + +### 7. Text files + +- [ ] `README.md` and `CONTRIBUTING.md`: replace the template's name, badges and links. + +## Check for leftovers + +Run this from the repository root. It should print nothing when you're done: + +```bash +grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ + --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . +``` + +If you kept the Java example or its folder name, `feature-hello` will still match; that's fine. Anything else is a missed rename. + +Then confirm nothing broke: + +```bash +./gradlew build +``` + +If you changed the chart, also run `helm lint charts/`. + +:::info[What you can skip for now] +You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. +::: + +Next: [write your node](./step-4-write-your-node.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-write-the-node.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-write-the-node.md deleted file mode 100644 index 6a2f9b0..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-write-the-node.md +++ /dev/null @@ -1,179 +0,0 @@ ---- -sidebar_position: 4 -sidebar_label: "3. Write the node" -title: "Step 3: Write the node" ---- - -# Step 3: Write the node - - - Step 3 of 9 - 33% through the guide - - -Put node classes in a `.node` subpackage. The platform derives your **feature ID** by removing the trailing `.node` segment from the class name. For example, `org.projectcontinuum.feature.demo.node.WordCounterNodeModel` gets the feature ID `org.projectcontinuum.feature.demo`. - -**`src/main/kotlin/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.kt`** - -```kotlin -package org.projectcontinuum.feature.demo.node - -import org.projectcontinuum.core.commons.annotation.ContinuumNode -import org.projectcontinuum.core.commons.exception.NodeRuntimeException -import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel -import org.projectcontinuum.core.commons.node.ProcessNodeModel -import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback -import org.projectcontinuum.core.commons.utils.NodeInputReader -import org.projectcontinuum.core.commons.utils.NodeOutputWriter -import org.slf4j.LoggerFactory -import org.springframework.http.MediaType.TEXT_PLAIN_VALUE -import tools.jackson.core.type.TypeReference -import tools.jackson.databind.ObjectMapper - -@ContinuumNode -class WordCounterNodeModel( - private val objectMapper: ObjectMapper -) : ProcessNodeModel() { - companion object { - private val LOGGER = LoggerFactory.getLogger(WordCounterNodeModel::class.java) - private val WHITESPACE = Regex("\\s+") - } - - // 1. Ports: the map keys ("data") are the port IDs used in execute() - final override val inputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "input table", contentType = TEXT_PLAIN_VALUE) - ) - final override val outputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "table with word counts", contentType = TEXT_PLAIN_VALUE) - ) - - // 2. Where the node appears in the workbench node explorer - override val categories = listOf("Demo") - - // 3. JSON Schema for the node's properties - val propertiesSchema: Map = objectMapper.readValue( - """ - { - "type": "object", - "properties": { - "inputCol": { "type": "string", "title": "Input Column" }, - "outputCol": { "type": "string", "title": "Output Column" }, - "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } - }, - "required": ["inputCol", "outputCol"] - } - """.trimIndent(), - object : TypeReference>() {} - ) - - // 4. JSON Forms UI schema: layout of the configuration dialog - val propertiesUiSchema: Map = objectMapper.readValue( - """ - { - "type": "VerticalLayout", - "elements": [ - { "type": "Control", "scope": "#/properties/inputCol" }, - { "type": "Control", "scope": "#/properties/outputCol" }, - { "type": "Control", "scope": "#/properties/minWordLength" } - ] - } - """.trimIndent(), - object : TypeReference>() {} - ) - - // 5. Metadata: what the workbench and registry see - override val metadata = ContinuumWorkflowModel.NodeData( - id = this.javaClass.name, - nodeModel = this.javaClass.name, - title = "Word Counter", - subTitle = "Count words per row", - description = "Counts the words in a text column and appends the count as a new column", - icon = """""", - inputs = inputPorts, - outputs = outputPorts, - properties = mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 1), - propertiesSchema = propertiesSchema, - propertiesUISchema = propertiesUiSchema - ) - - // 6. The node's logic - override fun execute( - properties: Map?, - inputs: Map, - nodeOutputWriter: NodeOutputWriter, - nodeProgressCallback: NodeProgressCallback - ) { - val inputCol = properties?.get("inputCol") as String? - ?: throw NodeRuntimeException(workflowId = "", nodeId = "", message = "inputCol is not provided") - val outputCol = properties["outputCol"] as String? - ?: throw NodeRuntimeException(workflowId = "", nodeId = "", message = "outputCol is not provided") - val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 - - val reader = inputs["data"] ?: throw NodeRuntimeException( - isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" - ) - val totalRows = reader.getRowCount() - - nodeOutputWriter.createOutputPortWriter("data").use { writer -> - reader.use { - var row = reader.read() - var rowNumber = 0L - while (row != null) { - val text = row[inputCol]?.toString() ?: "" - val count = text.trim().split(WHITESPACE).count { it.length >= minWordLength } - - writer.write(rowNumber, row.toMutableMap().apply { this[outputCol] = count }) - rowNumber++ - if (totalRows > 0) nodeProgressCallback.report((rowNumber * 100 / totalRows).toInt()) - row = reader.read() - } - LOGGER.info("Counted words in $rowNumber rows") - } - } - } -} -``` - -## The node contract - -| Rule | Why | -|------|-----| -| Annotate with `@ContinuumNode`, not `@Component`. | `@ContinuumNode` makes the bean prototype-scoped, so each execution gets a fresh instance. The build fails if a node class is missing it (see [Step 7](./step-7-build-and-test.md)). | -| Extend `ProcessNodeModel` for nodes with inputs, or `TriggerNodeModel` for source nodes. | `TriggerNodeModel` has only `outputPorts` and `execute(properties, nodeOutputWriter)`. | -| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The fully qualified class name is the node's identity in the registry and in saved workflows. Renaming or moving the class breaks existing workflows that use it. | -| Use Jackson 3 imports (`tools.jackson.*`). | Platform `0.0.20` is on Spring Boot 4 / Jackson 3. `com.fasterxml.jackson.databind` isn't on the classpath and won't compile. | -| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | - -## Properties and validation - -- `metadata.properties` holds the default values used when a node is dropped onto the canvas. -- Before `execute()` is called, `ProcessNodeModel.run()` **validates the configured properties against `propertiesSchema`**. Values that break `required`, `type`, `minimum` and similar rules fail the node before your code runs. You can still check values in `execute()` for clearer error messages. -- `propertiesUISchema` is a [JSON Forms](https://jsonforms.io/) UI schema, used only by the workbench to draw the configuration dialog. For credential pickers (`options.format = "credential"`), see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) before wiring them into a node. - -## Reading and writing rows - -- `inputs[portId]` is a `NodeInputReader`. `read()` returns the next row as `Map`, or `null` at the end of the table. `getRowCount()` returns the total number of rows. -- `nodeOutputWriter.createOutputPortWriter(portId)` returns a writer. `write(rowNumber, row)` takes a `Long` row index starting at `0`. -- Wrap both reader and writer in `.use { }`. The output Parquet file is only complete once the writer is closed. -- If an input port isn't connected, its key is missing from `inputs`. - -Cell values must be one of these types. Any other type makes `write()` throw `IllegalArgumentException: Unsupported type`. - -| Kotlin type | Stored as | -|-------------|-----------| -| `String` | `application/vnd.continuum.x-string` | -| `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | -| `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | -| `Boolean` | `application/vnd.continuum.x-boolean` | -| `List<*>`, `Map<*, *>` | `application/json` | -| SVG `org.w3c.dom.Document` | `image/svg+xml` | - -Convert anything else first, for example call `toString()` on a `LocalDate` or `BigDecimal`. A `null` value can't be stored either: leave the key out instead. - -## Errors and retries - -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors that a retry won't fix, such as missing configuration or a disconnected port. You can pass empty strings for `workflowId` and `nodeId`. The existing nodes do the same. - -## Progress - -Call `nodeProgressCallback.report(percent)` with a value from 0 to 100 as you go. The workbench uses it to show live progress on the node. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-node-documentation.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-node-documentation.md deleted file mode 100644 index e06e3d8..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-node-documentation.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -sidebar_position: 5 -sidebar_label: "4. Node documentation" -title: "Step 4: Add node documentation" ---- - -# Step 4: Add node documentation - - - Step 4 of 9 - 44% through the guide - - -Each node has a Markdown help page that the workbench shows next to it. It's loaded from the classpath on startup, at a path that matches the node's package and class name exactly: - -```text -src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md -``` - -If the file is missing, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. A good help page covers what the node does, its ports, a properties table, and a small input/output example. See the `.doc.md` files in [`continuum-feature-base`](https://github.com/projectcontinuum-org/continuum-feature-base) for the house style. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md new file mode 100644 index 0000000..37c4c4b --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md @@ -0,0 +1,253 @@ +--- +sidebar_position: 5 +sidebar_label: "4. Write your node" +title: "Step 4: Write your node" +--- + +# Step 4: Write your node + + + Step 4 of 6 + About 30 minutes + + +You don't start from a blank file. Rename the template's **Hello World** node and change what it does. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. + +A node is three files that share a name. Do them in this order: + +1. [The node class](#1-the-node-class) +2. [The help page](#2-the-help-page) +3. [The unit test](#3-the-unit-test) + +## 1. The node class + +Rename `HelloWorldNodeModel.kt` to `WordCounterNodeModel.kt` (and the class inside it). The file has six parts. Only the numbered ones need your changes: + +```text +@ContinuumNode ← required, never remove +class WordCounterNodeModel(...) : ProcessNodeModel() { + 1. ports what goes in and out + 2. categories where it appears in the palette + 3. propertiesSchema what settings exist, and what is valid + 4. propertiesUiSchema how the settings form looks + 5. metadata name, description, icon, defaults + 6. execute() the logic +} +``` + +Here is the finished Word Counter, with the six parts marked: + +```kotlin +package org.projectcontinuum.feature.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.ProcessNodeModel +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE +import tools.jackson.core.type.TypeReference +import tools.jackson.databind.ObjectMapper + +@ContinuumNode +class WordCounterNodeModel( + private val objectMapper: ObjectMapper +) : ProcessNodeModel() { + + private val whitespace = Regex("\\s+") + + // 1. Ports. The map keys ("data") are the port IDs you use in execute(). + final override val inputPorts = mapOf( + "data" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + final override val outputPorts = mapOf( + "data" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + + // 2. Palette category + override val categories = listOf("Demo") + + // 3. JSON Schema: the settings and their rules + private val propertiesSchema: Map = objectMapper.readValue( + """ + { + "type": "object", + "properties": { + "inputCol": { "type": "string", "title": "Input Column" }, + "outputCol": { "type": "string", "title": "Output Column" }, + "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } + }, + "required": ["inputCol", "outputCol"] + } + """.trimIndent(), + object : TypeReference>() {} + ) + + // 4. JSON Forms UI schema: the layout of the settings form + private val propertiesUiSchema: Map = objectMapper.readValue( + """ + { + "type": "VerticalLayout", + "elements": [ + { "type": "Control", "scope": "#/properties/inputCol" }, + { "type": "Control", "scope": "#/properties/outputCol" }, + { "type": "Control", "scope": "#/properties/minWordLength" } + ] + } + """.trimIndent(), + object : TypeReference>() {} + ) + + // 5. Metadata: what the Workbench and the registry see + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "Word Counter", + subTitle = "Count words per row", + description = "Counts the words in a text column and appends the count as a new column", + icon = """""", + inputs = inputPorts, + outputs = outputPorts, + properties = mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 1), + propertiesSchema = propertiesSchema, + propertiesUISchema = propertiesUiSchema + ) + + // 6. The logic + override fun execute( + properties: Map?, + inputs: Map, + nodeOutputWriter: NodeOutputWriter, + nodeProgressCallback: NodeProgressCallback + ) { + val inputCol = properties?.get("inputCol") as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "inputCol is not provided") + val outputCol = properties["outputCol"] as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "outputCol is not provided") + val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 + + val reader = inputs["data"] ?: throw NodeRuntimeException( + isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" + ) + val totalRows = reader.getRowCount() + + nodeOutputWriter.createOutputPortWriter("data").use { writer -> + reader.use { + var rowNumber = 0L + while (true) { + val row = reader.read() ?: break + val text = row[inputCol]?.toString() ?: "" + val count = text.trim().split(whitespace).count { it.length >= minWordLength } + + writer.write(rowNumber, row.toMutableMap().apply { this[outputCol] = count }) + rowNumber++ + if (totalRows > 0) nodeProgressCallback.report((rowNumber * 100 / totalRows).toInt()) + } + } + } + } +} +``` + +### Rules the platform enforces + +Break one of these and the build fails, the node doesn't load, or workflows break later. + +| Rule | Why | +|------|-----| +| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. | +| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | +| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | +| Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | +| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.databind` won't compile. | +| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | + +### Settings and validation + +- `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. +- Before `execute()` runs, the platform checks the user's settings against `propertiesSchema`. Values that break `required`, `type` or `minimum` fail the node before your code starts. Checking again in `execute()` is still worthwhile because it lets you give a clearer error message. +- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. + +### Reading and writing rows + +- `inputs["data"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. +- `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. +- Wrap both in `.use { }`. The output file is only complete once the writer is closed. + +Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Convert other types first (for example `toString()` on a `LocalDate`), and leave a key out instead of storing `null`. + +| Kotlin type | Stored as | +|-------------|-----------| +| `String` | `application/vnd.continuum.x-string` | +| `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | +| `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | +| `Boolean` | `application/vnd.continuum.x-boolean` | +| `List<*>`, `Map<*, *>` | `application/json` | +| SVG `org.w3c.dom.Document` | `image/svg+xml` | + +### Errors, retries and progress + +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as missing settings or an unconnected port. Empty strings are fine for `workflowId` and `nodeId`. + +Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. + +## 2. The help page + +Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. + +The path must match the node's package and class name exactly: + +```text +src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md +``` + +If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. + +A good help page has four parts, as in the template's Hello World page: what the node does, a **Configuration** table, a **Ports** table, and a small **Example** with input and output tables. + +## 3. The unit test + +Rename `HelloWorldNodeModelTest.kt` to `WordCounterNodeModelTest.kt`. Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. + +```kotlin +class WordCounterNodeModelTest { + private val outputWriter = mock() + private val portWriter = mock() + private val node = WordCounterNodeModel(jacksonObjectMapper()) + + @BeforeEach + fun setUp() { + whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) + } + + @Test + fun `counts words and keeps original columns`() { + val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) + + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) + + val rows = argumentCaptor>() + verify(portWriter).write(any(), rows.capture()) + assertEquals(4, rows.firstValue["word_count"]) + assertEquals(1, rows.firstValue["id"]) + } + + private fun mockReader(rows: List>): NodeInputReader { + val iterator = rows.iterator() + return mock().also { r -> + whenever(r.read()).thenAnswer { if (iterator.hasNext()) iterator.next() else null } + whenever(r.getRowCount()).thenReturn(rows.size.toLong()) + } + } +} +``` + +The template's `HelloWorldNodeModelTest` has more cases to copy, including metadata checks and progress reporting. + +:::note +These tests call `execute()` directly, so they skip the schema validation. To test validation as well, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. +::: + +Next: [test and run your node](./step-5-test-and-run.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md new file mode 100644 index 0000000..92851c8 --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md @@ -0,0 +1,63 @@ +--- +sidebar_position: 6 +sidebar_label: "5. Test and run" +title: "Step 5: Test and run your node" +--- + +# Step 5: Test and run your node + + + Step 5 of 6 + About 10 minutes + + +You ran the template unchanged in [Step 1](./step-1-clone-and-run.md). Now run it again with your changes. + +## 1. Build and test + +```bash +./gradlew build +``` + +This compiles every module, runs your unit tests, runs `validateContinuumNodeAnnotations` and builds the worker jar. To run one test class: + +```bash +./gradlew :features::test --tests "*WordCounterNodeModelTest" +``` + +:::note[The annotation check] +`validateContinuumNodeAnnotations` fails the build when a class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. If you see it fail, that's the cause. +::: + +## 2. Run the worker + +Make sure the local stack from Step 1 is still up (`docker compose ps` in `docker/`), then: + +```bash +./gradlew :worker:bootRun +``` + +## 3. Check the node was loaded + +Ask the worker which nodes it serves: + +```bash +curl http://localhost:8090/api/v1/node-repo +``` + +Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. The usual causes are, in order: + +1. The `.imports` file names the wrong class, or `AutoConfigure`'s `basePackages` doesn't cover your package ([Step 3](./step-3-make-it-yours.md#2-the-feature-module)). +2. `worker/build.gradle.kts` doesn't list your module. +3. The class is missing `@ContinuumNode`. + +## 4. Run it in the Workbench + +1. Open [http://localhost:3002](http://localhost:3002). **Word Counter** appears under **Demo**. +2. Add a table source that has a `text` column, such as **Create Table**, and connect it to Word Counter. +3. Open the Word Counter settings to see the form you defined, then run the workflow. +4. Click the output port. Every row has a new `word_count` column. + +You've now changed the template into your own working worker. + +Next: [ship it](./step-6-ship-it.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-unit-tests.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-unit-tests.md deleted file mode 100644 index fac9946..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-unit-tests.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -sidebar_position: 6 -sidebar_label: "5. Unit tests" -title: "Step 5: Write unit tests" ---- - -# Step 5: Write unit tests - - - Step 5 of 9 - 56% through the guide - - -`execute()` only depends on its arguments, so you can test it with Mockito mocks and no Spring context: - -**`src/test/kotlin/org/projectcontinuum/feature/demo/node/WordCounterNodeModelTest.kt`** - -```kotlin -class WordCounterNodeModelTest { - private val outputWriter = mock() - private val portWriter = mock() - private val node = WordCounterNodeModel(jacksonObjectMapper()) - - @BeforeEach - fun setUp() { - whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) - } - - @Test - fun `counts words and preserves original columns`() { - val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) - - node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) - - val rows = argumentCaptor>() - verify(portWriter).write(any(), rows.capture()) - assertEquals(4, rows.firstValue["word_count"]) - assertEquals(1, rows.firstValue["id"]) - } - - private fun mockReader(rows: List>): NodeInputReader { - val iterator = rows.iterator() - return mock().also { r -> - whenever(r.read()).thenAnswer { if (iterator.hasNext()) iterator.next() else null } - whenever(r.getRowCount()).thenReturn(rows.size.toLong()) - } - } -} -``` - -The imports come from `org.junit.jupiter.api`, `org.mockito.kotlin`, `kotlin.test` and `tools.jackson.module.kotlin.jacksonObjectMapper`. The feature plugin already adds all of them as test dependencies. - -These tests call `execute()` directly, so they skip the schema validation step. To test validation too, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md new file mode 100644 index 0000000..94bfff7 --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md @@ -0,0 +1,91 @@ +--- +sidebar_position: 7 +sidebar_label: "6. Ship it" +title: "Step 6: Ship it" +--- + +# Step 6: Ship it + + + Step 6 of 6 + Needs repository secrets + + +Shipping is mostly already set up in the template. This page explains what each piece does and what you need to provide. + +## The release flow + +```mermaid +flowchart TB + A["Bump featureVersion"] --> B["Open PR: CI checks run"] --> D["Merge to main"] --> E["Publish a GitHub release"] + E --> F["Feature modules to Maven Central
on-release.yml"] + E --> G["Worker image to Docker Hub
on-release.yml"] + E --> H["Helm chart to gh-pages
release.yml"] +``` + +## 1. Bump the version + +Every change under `features/` or `worker/` needs a new `featureVersion` in `gradle.properties`, and the chart's `appVersion` in `charts//Chart.yaml` must be set to the same value. + +CI enforces both on every pull request (`validate-versions.yml`). If your PR fails with "does not match featureVersion" or "featureVersion must be bumped", this is why. + +## 2. What CI runs + +| Workflow | When | What it does | +|----------|------|--------------| +| `ci.yml` | PR, push to `main` | `./gradlew build` | +| `validate-versions.yml` | PR | Checks the version rules above | +| `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | +| `build-module.yml` | Manual | Build one module, optionally publish it | +| `on-release.yml` | GitHub release | Libraries → Maven Central, worker → Docker Hub | +| `release.yml` | GitHub release | Package the Helm chart and update the `gh-pages` index | + +## 3. Add repository secrets + +The release workflows read these from your repository's **Settings → Secrets and variables → Actions**: + +| Secret | Used for | +|--------|----------| +| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | +| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | + +:::tip[Not publishing libraries?] +If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. +::: + +## 4. Deploy to Kubernetes + +The chart installs next to `continuum-infra` and `continuum-platform` in the same namespace: + +```bash +helm install ./charts/ -n continuum +``` + +Check these before you install: + +- `taskQueue` in `values.yaml` matches `node-task-queue` in `application.yaml`, and is unique. +- `image.repository` is the image your release pushes. +- The `continuum.infra.*` and `apiServer` hosts match the release names you used for `continuum-infra` and `continuum-platform`. + +See [Deployment](../../deployment/helm-charts.md) for the full setup. + +## Worker configuration reference + +You don't need to set Kafka, MinIO or the API server addresses; the worker starter ships defaults that match the local stack. Override them with environment variables when you deploy elsewhere: + +| Variable | Default | Purpose | +|----------|---------|---------| +| `CONTINUUM_NODE_TASK_QUEUE` | from `application.yaml` | This worker's Temporal task queue | +| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend | +| `TEMPORAL_NAMESPACE` | `default` | Temporal namespace | +| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | Where nodes register | +| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,localhost:39093,localhost:39094` | Kafka brokers | +| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Schema registry | +| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage for node data | +| `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` | MinIO credentials | +| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()` | +| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local scratch folder | +| `SERVER_PORT` | `8090` | Worker HTTP port (8080 belongs to the API server) | + +You're done. Your worker is live and its nodes are available in the Workbench. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-worker-module.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-worker-module.md deleted file mode 100644 index 48343e7..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-worker-module.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -sidebar_position: 7 -sidebar_label: "6. Worker module" -title: "Step 6: Create the worker module" ---- - -# Step 6: Create the worker module - - - Step 6 of 9 - 67% through the guide - - -**`worker/build.gradle.kts`** - -```kotlin -plugins { - id("org.projectcontinuum.worker") -} - -group = "org.projectcontinuum.app.worker.demo" -description = "Continuum Feature Demo Worker" -version = property("featureVersion").toString() - -continuum { - continuumVersion.set(property("continuumPlatformVersion").toString()) - // Optional: set this to build a container image with `./gradlew :worker:jib` - // jibToImage.set("docker.io/your-org/continuum-feature-demo:${version}") -} - -dependencies { - implementation(project(":features:continuum-feature-demo")) -} -``` - -**`worker/src/main/kotlin/org/projectcontinuum/app/worker/demo/App.kt`** - -```kotlin -package org.projectcontinuum.app.worker.demo - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.runApplication - -@SpringBootApplication -class App - -fun main(args: Array) { - runApplication(*args) -} -``` - -**`worker/src/main/resources/application.yaml`** - -```yaml -spring.application.name: continuum-feature-demo-worker - -# The worker runs a web server. Its default port 8080 clashes with -# continuum-api-server in the local stack. -server.port: ${SERVER_PORT:8090} - -spring: - temporal: - namespace: ${TEMPORAL_NAMESPACE:default} - connection: - target: ${TEMPORAL_SERVER_ADDRESS:localhost:7233} - workersAutoDiscovery: - packages: - - org.projectcontinuum.core.worker.starter - -continuum.core: - worker: - # Every worker needs its OWN task queue (see the warning below). - node-task-queue: ${CONTINUUM_NODE_TASK_QUEUE:CONTINUUM_FEATURE_DEMO_TASK_QUEUE} - -logging: - level: - root: error - org.projectcontinuum.core.worker: info - org.projectcontinuum.feature.demo: debug -``` - -:::danger[Give every worker a unique task queue] -If `node-task-queue` isn't set, a worker listens on the shared default queue `ACTIVITY_TASK_QUEUE`. When two workers share a queue, Temporal can send a node to a worker that doesn't have it, and the node fails. Every shipped worker sets its own queue (for example `CONTINUUM_FEATURE_BASE_TASK_QUEUE`), and yours must too. The worker sends its queue name in its registration message, so the orchestrator knows where to route your nodes. -::: - -## Environment variables - -You don't need to configure Kafka, MinIO, the API server or the credentials server here. `continuum-worker-springboot-starter` ships defaults that point at the [local stack](../../getting-started/local-setup.md) ports, and each one can be overridden with an environment variable: - -| Variable | Default | Purpose | -|----------|---------|---------| -| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend | -| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,localhost:39093,localhost:39094` | Kafka brokers for node registration | -| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Avro schema registry | -| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object store for Parquet inputs and outputs | -| `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` / `minioadmin` | MinIO credentials | -| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | API server | -| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only used by nodes that call `getCredential()` | -| `CONTINUUM_NODE_TASK_QUEUE` | none (falls back to `ACTIVITY_TASK_QUEUE`) | This worker's Temporal task queue | -| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local staging folder for Parquet files | diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-7-build-and-test.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-7-build-and-test.md deleted file mode 100644 index 664368f..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-7-build-and-test.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -sidebar_position: 8 -sidebar_label: "7. Build and test" -title: "Step 7: Build and test" ---- - -# Step 7: Build and test - - - Step 7 of 9 - 78% through the guide - - -```bash -./gradlew build -``` - -This compiles every module, runs `validateContinuumNodeAnnotations`, runs the unit tests and builds `worker/build/libs/worker-.jar`. - -To check that the annotation guard works, swap `@ContinuumNode` for `@Component` and run `./gradlew classes`. The build fails with: - -```text -> Task :features:continuum-feature-demo:validateContinuumNodeAnnotations FAILED - Continuum Node Annotation Validation Failed - The following classes implement ContinuumNodeModel but are missing the @ContinuumNode annotation: -``` diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-8-run-locally.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-8-run-locally.md deleted file mode 100644 index 6682dc3..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-8-run-locally.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -sidebar_position: 9 -sidebar_label: "8. Run locally" -title: "Step 8: Run the worker against the local stack" ---- - -# Step 8: Run the worker against the local stack - - - Step 8 of 9 - 89% through the guide - - -1. Start the platform with the [Local Setup](../../getting-started/local-setup.md) compose file and wait until every service is healthy. -2. Start your worker: - - ```bash - ./gradlew :worker:bootRun - ``` - -3. Check that the worker loaded your node. This endpoint returns the node tree that the worker serves: - - ```bash - curl http://localhost:8090/api/v1/node-repo - ``` - -4. Open the [workbench](http://127.0.0.1:3002). **Word Counter** appears under the **Demo** category. Drop it onto the canvas after a node that outputs a `text` column, such as **Create Table**, and run the workflow. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-9-ship-it.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-9-ship-it.md deleted file mode 100644 index 6e4ceba..0000000 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-9-ship-it.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -sidebar_position: 10 -sidebar_label: "9. Ship it" -title: "Step 9: Ship it" ---- - -# Step 9: Ship it - - - Step 9 of 9 - 100% through the guide - - -- **Container image:** set `jibToImage` in `worker/build.gradle.kts` and run `./gradlew :worker:jib`. Jib reads registry credentials from `DOCKER_REPO_USERNAME` / `DOCKER_REPO_PASSWORD`. The base image defaults to `eclipse-temurin:21-jre` and can be changed with `jibFromImage`. -- **Kubernetes:** deploy the worker as its own release in the platform's namespace and set the [environment variables](./step-6-worker-module.md#environment-variables) from Step 6, including a unique `CONTINUUM_NODE_TASK_QUEUE`. The charts in the existing feature repos (for example `continuum-feature-base/charts/`) are a working reference. See [Deployment](../../deployment/helm-charts.md). -- **Publishing feature modules:** the plugins configure Maven Central publishing through JReleaser by default. If you don't publish libraries, set `publishToMavenCentral.set(false)` in the `continuum { }` block. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md index c714d8e..c9bad42 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md @@ -1,18 +1,31 @@ --- -sidebar_position: 11 +sidebar_position: 8 sidebar_label: Troubleshooting title: Troubleshooting --- # Troubleshooting +## My node doesn't show up in the Workbench + +Work down this list. Each item is a more common cause than the next. + +1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the problem is on the Workbench or platform side; refresh the page and check the local stack is healthy. +2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`. +3. **Does Spring find the module?** The `.imports` file must contain the full name of your `AutoConfigure` class, and `AutoConfigure`'s `@ComponentScan(basePackages = ...)` must cover your node's package. See [Step 3](./step-3-make-it-yours.md#2-the-feature-module). +4. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. + +## Errors + | Symptom | Cause and fix | |---------|---------------| -| `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | That version isn't on Maven Central (for example an old `-SNAPSHOT`), or `mavenCentral()` is missing from `pluginManagement.repositories`. Use a released `continuumPlatformVersion`. See [Step 1](./step-1-root-project.md). | -| `Unresolved reference 'databind'` / `'ObjectMapper'` | You're using Jackson 2 imports (`com.fasterxml.jackson.*`). Switch to `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | +| `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | +| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | -| Worker starts but your node isn't listed | The `AutoConfiguration.imports` file is missing or points at the wrong class, or the node is outside the `AutoConfigure` package. See [Step 2](./step-2-feature-module.md#register-the-module-with-spring). | -| `Port 8080 was already in use` on `bootRun` | The local API server already uses 8080. Set `server.port` (see [Step 6](./step-6-worker-module.md)). | -| Node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `CONTINUUM_NODE_TASK_QUEUE`. | -| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't one of the [supported types](./step-3-write-the-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-node-documentation.md). | +| `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | +| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | +| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | +| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows. | diff --git a/versioned_docs/version-0.0.20/contributing/feature-template.md b/versioned_docs/version-0.0.20/contributing/feature-template.md index 6a8239b..244b8db 100644 --- a/versioned_docs/version-0.0.20/contributing/feature-template.md +++ b/versioned_docs/version-0.0.20/contributing/feature-template.md @@ -11,7 +11,7 @@ Continuum is designed to be extended by **adding new workers**, not modifying ex To build your own set of nodes, start from [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) — a scaffold for a standalone Gradle project with the Spring Boot worker setup, Temporal registration, and `@ContinuumNode` conventions already wired up. :::tip -The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. Its README covers renaming it for your own feature. For a walkthrough of writing a node from scratch, see [Create New Nodes](./create-new-nodes/overview.md). +The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it and writing your first node, see [Create New Nodes](./create-new-nodes/overview.md). ::: Once your worker is running and registering nodes, it can be deployed as an independent release into the same Kubernetes namespace as the core platform (see [Deployment](../deployment/helm-charts.md)) — no changes to `continuum-platform-core` or any other feature repo required. diff --git a/versions.json b/versions.json index f6d5e7b..099d322 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1 @@ -[ - "0.0.20" -] +["0.0.20"] From 8206c873681a477143fc57e939965752e9397261 Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 07:50:10 +0000 Subject: [PATCH 2/6] CONTNM-137: Updated by copilot --- .../step-2-tour-the-template.md | 20 +++-- .../create-new-nodes/step-3-make-it-yours.md | 41 ++++++++-- .../step-4-write-your-node.md | 45 ++++++++-- .../create-new-nodes/step-5-test-and-run.md | 73 +++++++++++++++-- .../create-new-nodes/step-6-ship-it.md | 75 ++++++++++++----- .../create-new-nodes/troubleshooting.md | 82 ++++++++++++++++--- 6 files changed, 279 insertions(+), 57 deletions(-) diff --git a/docs/contributing/create-new-nodes/step-2-tour-the-template.md b/docs/contributing/create-new-nodes/step-2-tour-the-template.md index 83a3b07..839a192 100644 --- a/docs/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/docs/contributing/create-new-nodes/step-2-tour-the-template.md @@ -83,14 +83,24 @@ These three live side by side in each feature module and share a name: ### Files that connect your nodes to the platform -If you get one of these wrong, the build still passes but **the worker starts with no nodes**. These are the most common reasons a new node doesn't appear. +⚠️ **CRITICAL: Silent Failures Below** — If you get one of these wrong, the build still passes but **the worker starts with no nodes**. No error message, no warning. These are the most common reasons a new node doesn't appear. Check all three in Step 5 before debugging further. | File | Why it matters | |------|----------------| -| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. | -| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. | -| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | -| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | +| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. **If `basePackages` is wrong or doesn't include your node's package, the node won't be found.** | +| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. **If this file name is wrong or doesn't exist, Spring won't load your module at all.** | +| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. **If your module is missing from this list, it won't be part of the worker.** | +| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. **If your class is in the wrong package, it won't be discovered.** | + +:::warning[Pre-Flight Check for Step 5] +After you write your node in Step 4, before debugging why it doesn't appear, verify these three files: + +1. `worker/build.gradle.kts` lists your module: `implementation(project(":features:"))` +2. `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports` contains: `.AutoConfigure` +3. `AutoConfigure.kt` has `@ComponentScan(basePackages = [""])` + +If all three are correct but the node still doesn't appear, then check the node class itself has `@ContinuumNode`. +::: ### Files that must agree with each other diff --git a/docs/contributing/create-new-nodes/step-3-make-it-yours.md b/docs/contributing/create-new-nodes/step-3-make-it-yours.md index e46fbfd..a7e98c2 100644 --- a/docs/contributing/create-new-nodes/step-3-make-it-yours.md +++ b/docs/contributing/create-new-nodes/step-3-make-it-yours.md @@ -13,13 +13,23 @@ title: "Step 3: Make it yours" The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. -The examples below use these placeholders. Pick your values first: - -| Placeholder | Example | Used for | -|-------------|---------|----------| -| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | -| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | -| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique.** | +**⚠️ Before you start:** Choose these three names and search the other Continuum repositories to confirm they're not already in use: + +| Placeholder | Example | Used for | ⚠️ Warning | +|-------------|---------|----------|-----------| +| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Can be changed later (cumbersome but possible) | +| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Changing this breaks saved workflows. **Don't change after shipping.** | +| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be globally unique across all workers in your Continuum instance.** | If two workers share this queue, Temporal randomly assigns node work to either worker, causing random failures. **Pick this carefully.** | + +:::danger[Task Queue Uniqueness is Critical] +If two different workers have the same `node-task-queue` value: +- Temporal will assign work to whichever worker polls first +- A worker without a particular node will receive its work and fail +- Users see random node failures with no clear cause +- There is no error message to warn you + +**Search all other continuum feature workers in your organization before picking a name.** +::: ## Checklist @@ -103,8 +113,25 @@ Then confirm nothing broke: If you changed the chart, also run `helm lint charts/`. +### ✅ Verification Checklist for Step 3 + +Before moving to Step 4, verify these critical synchronization points: + +- [ ] **Project name** in `settings.gradle.kts` matches folder names +- [ ] **Module includes** in `settings.gradle.kts` match actual folders +- [ ] **Module reference** in `worker/build.gradle.kts` matches the include +- [ ] **AutoConfigure class name** in `META-INF/spring/…AutoConfiguration.imports` matches the actual class +- [ ] **Task queue** in `application.yaml` matches Helm `values.yaml` (if updated) +- [ ] **Feature version** in `gradle.properties` matches chart `appVersion` (if updated) +- [ ] **No template names remain** (grep check clean) +- [ ] **Build passes** (`./gradlew build`) +- [ ] **Helm lint passes** (if you updated the chart: `helm lint charts/`) + :::info[What you can skip for now] You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. + +**However**, if you skip Helm chart and workflows, still update the task queue value in sections 4, since it affects local testing. ::: Next: [write your node](./step-4-write-your-node.md). + diff --git a/docs/contributing/create-new-nodes/step-4-write-your-node.md b/docs/contributing/create-new-nodes/step-4-write-your-node.md index 37c4c4b..774cb04 100644 --- a/docs/contributing/create-new-nodes/step-4-write-your-node.md +++ b/docs/contributing/create-new-nodes/step-4-write-your-node.md @@ -157,13 +157,27 @@ Break one of these and the build fails, the node doesn't load, or workflows brea | Rule | Why | |------|-----| -| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. | +| **Annotate with `@ContinuumNode`, not `@Component`.** | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. If missing, no error but node won't load. | | Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | -| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | +| **Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`.** | The full class name is the node's identity in saved workflows. **If you rename or move the class later, all saved workflows using this node will break permanently. Don't do this once you've shipped.** | | Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | -| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.databind` won't compile. | +| **Import Jackson from `tools.jackson.*` (Jackson 3).** | The platform uses Jackson 3. Importing from `com.fasterxml.jackson.*` (Jackson 2) won't compile. This is a common mistake. Make sure all Jackson imports use `tools.jackson.*`. | | Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | +### Port Configuration + +The `inputPorts` and `outputPorts` are Maps where: +- **Key** (e.g., `"data"`) is the **port ID** you use in `execute()` to read/write data +- **Value** is a `ContinuumWorkflowModel.NodePort` with: + - `name` — human-readable name shown in Workbench (e.g., "Input Table") + - `contentType` — MIME type of data flowing through the port + +**Standard Content Types**: +- `APPLICATION_OCTET_STREAM_VALUE` (`"application/octet-stream"`) — Used for table data (most common) +- Other types can be used for specialized data, but table-based nodes almost always use `application/octet-stream` + +All ports in the running example use `APPLICATION_OCTET_STREAM_VALUE`. If you need a different type, refer to the [Node Model & Feature Registration](../../architecture/node-model.md) documentation. + ### Settings and validation - `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. @@ -176,7 +190,7 @@ Break one of these and the build fails, the node doesn't load, or workflows brea - `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. - Wrap both in `.use { }`. The output file is only complete once the writer is closed. -Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Convert other types first (for example `toString()` on a `LocalDate`), and leave a key out instead of storing `null`. +**Allowed Cell Types** — Only these types can be written. Anything else will throw `IllegalArgumentException: Unsupported type` at runtime. Never use `null`; omit the key instead. | Kotlin type | Stored as | |-------------|-----------| @@ -187,9 +201,16 @@ Cell values must be one of these types, and never `null`. Anything else makes `w | `List<*>`, `Map<*, *>` | `application/json` | | SVG `org.w3c.dom.Document` | `image/svg+xml` | +⚠️ **Not allowed**: `null`, `LocalDate`, `BigDecimal`, custom objects. Convert to one of the allowed types first. For example: `LocalDate` → call `.toString()` for a `String`. + ### Errors, retries and progress -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as missing settings or an unconnected port. Empty strings are fine for `workflowId` and `nodeId`. +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as: +- Missing or invalid settings (user error) +- An unconnected input port +- Invalid input data that can't be recovered from + +Empty strings are fine for `workflowId` and `nodeId` in the exception. Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. @@ -197,13 +218,21 @@ Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. -The path must match the node's package and class name exactly: +**The path must match the node's package and class name exactly, or the help will show as "Documentation not found":** +For class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`: ```text -src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md +✓ CORRECT: + src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md + +✗ WRONG (no error, but help will be missing): + src/main/resources/org/projectcontinuum/feature/demo/WordCounterNodeModel.doc.md + src/main/resources/demo/node/WordCounterNodeModel.doc.md ``` -If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. +**Path construction rule**: Replace `.` with `/` in your package name, then append `/node/` and your class name + `.doc.md`. + +If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. There's no build error to warn you. A good help page has four parts, as in the template's Hello World page: what the node does, a **Configuration** table, a **Ports** table, and a small **Example** with input and output tables. diff --git a/docs/contributing/create-new-nodes/step-5-test-and-run.md b/docs/contributing/create-new-nodes/step-5-test-and-run.md index 92851c8..9a47e2e 100644 --- a/docs/contributing/create-new-nodes/step-5-test-and-run.md +++ b/docs/contributing/create-new-nodes/step-5-test-and-run.md @@ -45,11 +45,47 @@ Ask the worker which nodes it serves: curl http://localhost:8090/api/v1/node-repo ``` -Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. The usual causes are, in order: - -1. The `.imports` file names the wrong class, or `AutoConfigure`'s `basePackages` doesn't cover your package ([Step 3](./step-3-make-it-yours.md#2-the-feature-module)). -2. `worker/build.gradle.kts` doesn't list your module. -3. The class is missing `@ContinuumNode`. +Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. Work through these checks in order (most common first): + +### Pre-Flight Checklist - Node Not Appearing + +This is a **silent failure**. The build passes, the worker runs, but your node doesn't appear. + +- [ ] **Check the module is in the worker** + ```bash + grep "implementation(project" worker/build.gradle.kts + ``` + Should contain: `implementation(project(":features:"))` + + **If missing**: Add it and rebuild. + +- [ ] **Check the AutoConfigure class is named in the .imports file** + ```bash + cat worker/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports + ``` + Should contain exactly: `.AutoConfigure` + + **If wrong**: Fix the class name and rebuild. + +- [ ] **Check AutoConfigure scans your package** + Look at `features//src/main/kotlin//AutoConfigure.kt`: + ```kotlin + @ComponentScan(basePackages = [""]) + ``` + Should include your package. Your node class must be in this package or a subpackage. + + **If wrong**: Update `basePackages` and rebuild. + +- [ ] **Check your node class has the annotation** + Look at `features//src/main/kotlin//node/NodeModel.kt`: + ```kotlin + @ContinuumNode + class YourNodeModel(...) : ProcessNodeModel() { ... } + ``` + + **If missing**: Add `@ContinuumNode` and rebuild. + +If all four checks pass, restart the worker and try again. ## 4. Run it in the Workbench @@ -58,6 +94,33 @@ Your **Word Counter** should be in the response. If it isn't, the worker didn't 3. Open the Word Counter settings to see the form you defined, then run the workflow. 4. Click the output port. Every row has a new `word_count` column. +### Verify the Help Page + +While in the Workbench, look for a help icon or panel next to your node. It should show documentation from your `.doc.md` file. If it says "Documentation not found", the file path doesn't match. See [Step 4 - The help page](./step-4-write-your-node.md#2-the-help-page). + +## 5. Configuration reference for local testing + +When running locally (`./gradlew :worker:bootRun`), these values are used by default. You can override them with environment variables when deploying elsewhere: + +| Variable | Local default | What it controls | +|----------|---------------|------------------| +| `CONTINUUM_NODE_TASK_QUEUE` | from `application.yaml` | This worker's Temporal task queue | +| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend address | +| `TEMPORAL_NAMESPACE` | `default` | Temporal namespace | +| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | API server for node registration | +| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,39093,39094` | Kafka brokers | +| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Avro schema registry | +| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage endpoint | +| `CONTINUUM_MINIO_USERNAME` | `minioadmin` | MinIO credentials | +| `CONTINUUM_MINIO_PASSWORD` | `minioadmin` | MinIO credentials | +| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local data cache directory | +| `SERVER_PORT` | `8090` | Worker HTTP port (keep 8090 locally; 8080 is for API server) | + +For nodes that call `getCredential()`, also set: +| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Credentials service | + +Locally, you don't need to change these. The defaults work with the local stack from Step 1. + You've now changed the template into your own working worker. Next: [ship it](./step-6-ship-it.md). diff --git a/docs/contributing/create-new-nodes/step-6-ship-it.md b/docs/contributing/create-new-nodes/step-6-ship-it.md index 94bfff7..030d806 100644 --- a/docs/contributing/create-new-nodes/step-6-ship-it.md +++ b/docs/contributing/create-new-nodes/step-6-ship-it.md @@ -17,18 +17,44 @@ Shipping is mostly already set up in the template. This page explains what each ```mermaid flowchart TB - A["Bump featureVersion"] --> B["Open PR: CI checks run"] --> D["Merge to main"] --> E["Publish a GitHub release"] - E --> F["Feature modules to Maven Central
on-release.yml"] - E --> G["Worker image to Docker Hub
on-release.yml"] - E --> H["Helm chart to gh-pages
release.yml"] + A["Bump featureVersion in gradle.properties
Update appVersion in Chart.yaml
(must match)"] --> B["Open PR: CI checks run"] + B --> C{Pass CI?} + C -->|No| D["Fix and push again"] + D --> B + C -->|Yes| E["Merge to main"] + E --> F["Go to GitHub Releases page"] + F --> G["Click 'Create a new release'"] + G --> H["GitHub release triggers workflows"] + H --> I["Feature modules to Maven Central"] + H --> J["Worker image to Docker Hub"] + H --> K["Helm chart to gh-pages"] ``` +:::warning[Key Step: Create a GitHub Release] +After merging to main, you must go to the GitHub UI and create a release. Don't just tag the commit or push a version. **Go to:** Repository → Releases → Create a new release + +This triggers the `on-release.yml` and `release.yml` workflows that publish your artifacts. +::: + ## 1. Bump the version -Every change under `features/` or `worker/` needs a new `featureVersion` in `gradle.properties`, and the chart's `appVersion` in `charts//Chart.yaml` must be set to the same value. +Every change under `features/` or `worker/` needs: +1. A new `featureVersion` in `gradle.properties` +2. The chart's `appVersion` in `charts//Chart.yaml` set to the **same value** CI enforces both on every pull request (`validate-versions.yml`). If your PR fails with "does not match featureVersion" or "featureVersion must be bumped", this is why. +**Example:** +```properties +# gradle.properties +featureVersion=0.0.2 +``` + +```yaml +# charts//Chart.yaml +appVersion: "0.0.2" # Must match gradle.properties +``` + ## 2. What CI runs | Workflow | When | What it does | @@ -37,38 +63,45 @@ CI enforces both on every pull request (`validate-versions.yml`). If your PR fai | `validate-versions.yml` | PR | Checks the version rules above | | `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | | `build-module.yml` | Manual | Build one module, optionally publish it | -| `on-release.yml` | GitHub release | Libraries → Maven Central, worker → Docker Hub | -| `release.yml` | GitHub release | Package the Helm chart and update the `gh-pages` index | +| `on-release.yml` | ⭐ **GitHub release published** | Libraries → Maven Central, worker → Docker Hub | +| `release.yml` | ⭐ **GitHub release published** | Package the Helm chart and update the `gh-pages` index | + +:::info[Workflows are triggered by Release, not by Tag or Push] +The workflows that publish your artifacts (`on-release.yml` and `release.yml`) run when you **publish a GitHub Release**. They don't run on tags or commits. You must explicitly create a release in the GitHub UI. +::: ## 3. Add repository secrets The release workflows read these from your repository's **Settings → Secrets and variables → Actions**: -| Secret | Used for | -|--------|----------| -| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | -| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | -| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | +| Secret | Used for | Required? | +|--------|----------|-----------| +| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | If publishing to Maven Central | +| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | If publishing to Maven Central | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, always needed | :::tip[Not publishing libraries?] If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. + +You still need Docker Hub secrets to publish the worker image. ::: -## 4. Deploy to Kubernetes +## 4. Verify before deployment + +Before installing the chart to Kubernetes, verify these critical synchronization points: -The chart installs next to `continuum-infra` and `continuum-platform` in the same namespace: +- [ ] `taskQueue` in `charts//values.yaml` matches `node-task-queue` in `application.yaml` +- [ ] `taskQueue` is globally unique (search other workers) +- [ ] `image.repository` in values.yaml matches what your release pushes to Docker Hub +- [ ] The `continuum.infra.*` and `apiServer` hosts match the release names of other Continuum services + +Then install: ```bash helm install ./charts/ -n continuum ``` -Check these before you install: - -- `taskQueue` in `values.yaml` matches `node-task-queue` in `application.yaml`, and is unique. -- `image.repository` is the image your release pushes. -- The `continuum.infra.*` and `apiServer` hosts match the release names you used for `continuum-infra` and `continuum-platform`. - -See [Deployment](../../deployment/helm-charts.md) for the full setup. +See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup. ## Worker configuration reference diff --git a/docs/contributing/create-new-nodes/troubleshooting.md b/docs/contributing/create-new-nodes/troubleshooting.md index c9bad42..9679276 100644 --- a/docs/contributing/create-new-nodes/troubleshooting.md +++ b/docs/contributing/create-new-nodes/troubleshooting.md @@ -8,24 +8,84 @@ title: Troubleshooting ## My node doesn't show up in the Workbench -Work down this list. Each item is a more common cause than the next. +This is the most common issue. The build passes but your node isn't in the palette. Work through this checklist in order. -1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the problem is on the Workbench or platform side; refresh the page and check the local stack is healthy. -2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`. -3. **Does Spring find the module?** The `.imports` file must contain the full name of your `AutoConfigure` class, and `AutoConfigure`'s `@ComponentScan(basePackages = ...)` must cover your node's package. See [Step 3](./step-3-make-it-yours.md#2-the-feature-module). -4. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. +### Quick Diagnostic + +First, verify the worker is running and check the node repository: + +```bash +# Is the worker healthy? +curl http://localhost:8090/actuator/health + +# Does it have any nodes registered? +curl http://localhost:8090/api/v1/node-repo +``` + +If you don't see your node in the JSON response, continue below. + +### Pre-Flight Checklist (Most Common Issues) + +These four things are the most common causes. Check all four: + +1. **Module is listed in worker/build.gradle.kts** + ```bash + grep "implementation(project" worker/build.gradle.kts + ``` + Should show: `implementation(project(":features:"))` + + **If missing**: Add it, rebuild, and restart the worker. + +2. **.imports file names the correct AutoConfigure class** + ```bash + cat worker/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports + ``` + Should show exactly: `.AutoConfigure` + + **If wrong**: Fix the class name, rebuild, and restart. + +3. **AutoConfigure.kt has correct @ComponentScan** + Look at `features//src/main/kotlin//AutoConfigure.kt`: + ```kotlin + @ComponentScan(basePackages = [""]) + ``` + Your node must be in this package or a subpackage. + + **If wrong**: Update basePackages, rebuild, and restart. + +4. **Your node class has @ContinuumNode annotation** + ```kotlin + @ContinuumNode + class YourNodeModel(...) : ProcessNodeModel() { ... } + ``` + + **If missing**: Add the annotation, rebuild, and restart. + +:::tip[After fixing any of these, don't forget to restart the worker] +Changes in Gradle files and annotations require a rebuild and worker restart. Just reloading the browser won't work. +::: + +### Still Not Appearing? + +If all four items above are correct, try these additional checks: + +- **Is your node in the right package?** It must be in a package ending in `.node`, and under the package scanned by `AutoConfigure`. +- **Did you run `./gradlew build`?** The build validates annotations and can catch errors earlier. +- **Are there compilation errors?** Check the build output for Jackson or other import errors. +- **Try restarting the whole stack**: Stop the worker, kill the containers, restart them, and start the worker again. ## Errors | Symptom | Cause and fix | |---------|---------------| | `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | -| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | +| `Unresolved reference 'databind'` / `'ObjectMapper'` | **Jackson 2 imports instead of Jackson 3.** Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. Not `com.fasterxml.jackson.*`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | | `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | -| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | -| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| **A node fails at random, or runs on the wrong worker** | **Several workers share a task queue** (critical issue). Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. Search other continuum workers before picking a name. | +| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (not String, Int, Long, Float, Double, Boolean, List, Map, or SVG). Convert to one of these types first, or omit the key instead of using null. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | +| **Help page reads "Documentation not found"** | **The `.doc.md` file path doesn't match the node's package and class name exactly.** Path must be: `src/main/resources//node/.doc.md`. See [Step 4 - The help page](./step-4-write-your-node.md#2-the-help-page). | | Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | -| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | -| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows. | +| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the **same value**. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| **Saved workflows break after a rename** | **You renamed or moved a node class. The full class name is the node's identity in saved workflows. This is permanent.** Don't rename classes after shipping. | + From 8c9fb880089571718254d8f9b47f62227aee9839 Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 15:55:37 +0530 Subject: [PATCH 3/6] CONTNM-137: fix some refs --- .../step-2-tour-the-template.md | 20 ++--- .../create-new-nodes/step-3-make-it-yours.md | 45 ++++------- .../step-4-write-your-node.md | 39 ++++----- .../create-new-nodes/step-5-test-and-run.md | 70 +--------------- .../create-new-nodes/step-6-ship-it.md | 14 ++-- .../create-new-nodes/troubleshooting.md | 79 ++++--------------- 6 files changed, 59 insertions(+), 208 deletions(-) diff --git a/docs/contributing/create-new-nodes/step-2-tour-the-template.md b/docs/contributing/create-new-nodes/step-2-tour-the-template.md index 839a192..52640c7 100644 --- a/docs/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/docs/contributing/create-new-nodes/step-2-tour-the-template.md @@ -83,24 +83,16 @@ These three live side by side in each feature module and share a name: ### Files that connect your nodes to the platform -⚠️ **CRITICAL: Silent Failures Below** — If you get one of these wrong, the build still passes but **the worker starts with no nodes**. No error message, no warning. These are the most common reasons a new node doesn't appear. Check all three in Step 5 before debugging further. +If you get one of the first three wrong, the build still passes but **the worker starts with no nodes**, and nothing in the build output tells you why. These are the most common reasons a new node doesn't appear. | File | Why it matters | |------|----------------| -| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. **If `basePackages` is wrong or doesn't include your node's package, the node won't be found.** | -| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. **If this file name is wrong or doesn't exist, Spring won't load your module at all.** | -| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. **If your module is missing from this list, it won't be part of the worker.** | -| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. **If your class is in the wrong package, it won't be discovered.** | +| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. If `basePackages` doesn't cover your node's package, the node isn't found. | +| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. If the file is missing or names the wrong class, Spring doesn't load your module. | +| `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | +| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | -:::warning[Pre-Flight Check for Step 5] -After you write your node in Step 4, before debugging why it doesn't appear, verify these three files: - -1. `worker/build.gradle.kts` lists your module: `implementation(project(":features:"))` -2. `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports` contains: `.AutoConfigure` -3. `AutoConfigure.kt` has `@ComponentScan(basePackages = [""])` - -If all three are correct but the node still doesn't appear, then check the node class itself has `@ContinuumNode`. -::: +If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). ### Files that must agree with each other diff --git a/docs/contributing/create-new-nodes/step-3-make-it-yours.md b/docs/contributing/create-new-nodes/step-3-make-it-yours.md index a7e98c2..eb241d7 100644 --- a/docs/contributing/create-new-nodes/step-3-make-it-yours.md +++ b/docs/contributing/create-new-nodes/step-3-make-it-yours.md @@ -13,23 +13,13 @@ title: "Step 3: Make it yours" The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. -**⚠️ Before you start:** Choose these three names and search the other Continuum repositories to confirm they're not already in use: - -| Placeholder | Example | Used for | ⚠️ Warning | -|-------------|---------|----------|-----------| -| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Can be changed later (cumbersome but possible) | -| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Changing this breaks saved workflows. **Don't change after shipping.** | -| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be globally unique across all workers in your Continuum instance.** | If two workers share this queue, Temporal randomly assigns node work to either worker, causing random failures. **Pick this carefully.** | - -:::danger[Task Queue Uniqueness is Critical] -If two different workers have the same `node-task-queue` value: -- Temporal will assign work to whichever worker polls first -- A worker without a particular node will receive its work and fail -- Users see random node failures with no clear cause -- There is no error message to warn you - -**Search all other continuum feature workers in your organization before picking a name.** -::: +Pick your values first, and check the other Continuum repositories to make sure the names aren't already in use: + +| Placeholder | Example | Used for | Changing it later | +|-------------|---------|----------|-------------------| +| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Possible, but you repeat this whole step. | +| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | +| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique across all workers in your Continuum instance.** | Change it in `application.yaml` and the chart together. | ## Checklist @@ -113,24 +103,17 @@ Then confirm nothing broke: If you changed the chart, also run `helm lint charts/`. -### ✅ Verification Checklist for Step 3 +### Before you move on -Before moving to Step 4, verify these critical synchronization points: - -- [ ] **Project name** in `settings.gradle.kts` matches folder names -- [ ] **Module includes** in `settings.gradle.kts` match actual folders -- [ ] **Module reference** in `worker/build.gradle.kts` matches the include -- [ ] **AutoConfigure class name** in `META-INF/spring/…AutoConfiguration.imports` matches the actual class -- [ ] **Task queue** in `application.yaml` matches Helm `values.yaml` (if updated) -- [ ] **Feature version** in `gradle.properties` matches chart `appVersion` (if updated) -- [ ] **No template names remain** (grep check clean) -- [ ] **Build passes** (`./gradlew build`) -- [ ] **Helm lint passes** (if you updated the chart: `helm lint charts/`) +- [ ] The module folder, the `include(...)` line in `settings.gradle.kts` and the `implementation(project(...))` line in `worker/build.gradle.kts` all use the same module name. +- [ ] The `.imports` file names your real `AutoConfigure` class. +- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml` (if you updated the chart). +- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml` (if you updated the chart). +- [ ] The leftover grep above prints nothing. +- [ ] `./gradlew build` passes, and `helm lint charts/` passes if you changed the chart. :::info[What you can skip for now] You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. - -**However**, if you skip Helm chart and workflows, still update the task queue value in sections 4, since it affects local testing. ::: Next: [write your node](./step-4-write-your-node.md). diff --git a/docs/contributing/create-new-nodes/step-4-write-your-node.md b/docs/contributing/create-new-nodes/step-4-write-your-node.md index 774cb04..7e001cb 100644 --- a/docs/contributing/create-new-nodes/step-4-write-your-node.md +++ b/docs/contributing/create-new-nodes/step-4-write-your-node.md @@ -157,26 +157,21 @@ Break one of these and the build fails, the node doesn't load, or workflows brea | Rule | Why | |------|-----| -| **Annotate with `@ContinuumNode`, not `@Component`.** | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. If missing, no error but node won't load. | +| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it (`validateContinuumNodeAnnotations`). | | Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | -| **Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`.** | The full class name is the node's identity in saved workflows. **If you rename or move the class later, all saved workflows using this node will break permanently. Don't do this once you've shipped.** | +| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | | Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | -| **Import Jackson from `tools.jackson.*` (Jackson 3).** | The platform uses Jackson 3. Importing from `com.fasterxml.jackson.*` (Jackson 2) won't compile. This is a common mistake. Make sure all Jackson imports use `tools.jackson.*`. | +| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.*` (Jackson 2) won't compile. | | Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | -### Port Configuration +### Ports -The `inputPorts` and `outputPorts` are Maps where: -- **Key** (e.g., `"data"`) is the **port ID** you use in `execute()` to read/write data -- **Value** is a `ContinuumWorkflowModel.NodePort` with: - - `name` — human-readable name shown in Workbench (e.g., "Input Table") - - `contentType` — MIME type of data flowing through the port +`inputPorts` and `outputPorts` are maps: -**Standard Content Types**: -- `APPLICATION_OCTET_STREAM_VALUE` (`"application/octet-stream"`) — Used for table data (most common) -- Other types can be used for specialized data, but table-based nodes almost always use `application/octet-stream` +- The **key** (for example `"data"`) is the port ID you use in `execute()` to read or write data. +- The **value** is a `ContinuumWorkflowModel.NodePort` with a `name` (shown in the Workbench) and a `contentType`. -All ports in the running example use `APPLICATION_OCTET_STREAM_VALUE`. If you need a different type, refer to the [Node Model & Feature Registration](../../architecture/node-model.md) documentation. +Table ports use `APPLICATION_OCTET_STREAM_VALUE`, as in the running example. The template's example nodes do the same. ### Settings and validation @@ -190,7 +185,7 @@ All ports in the running example use `APPLICATION_OCTET_STREAM_VALUE`. If you ne - `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. - Wrap both in `.use { }`. The output file is only complete once the writer is closed. -**Allowed Cell Types** — Only these types can be written. Anything else will throw `IllegalArgumentException: Unsupported type` at runtime. Never use `null`; omit the key instead. +Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Leave a key out instead of storing `null`. | Kotlin type | Stored as | |-------------|-----------| @@ -201,7 +196,7 @@ All ports in the running example use `APPLICATION_OCTET_STREAM_VALUE`. If you ne | `List<*>`, `Map<*, *>` | `application/json` | | SVG `org.w3c.dom.Document` | `image/svg+xml` | -⚠️ **Not allowed**: `null`, `LocalDate`, `BigDecimal`, custom objects. Convert to one of the allowed types first. For example: `LocalDate` → call `.toString()` for a `String`. +Convert anything else first. For example, call `toString()` on a `LocalDate`, and convert a `BigDecimal` to a `Double` or a `String`. ### Errors, retries and progress @@ -218,21 +213,15 @@ Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. -**The path must match the node's package and class name exactly, or the help will show as "Documentation not found":** +The path must match the node's package and class name exactly. For the class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`, the file is: -For class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`: ```text -✓ CORRECT: - src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md - -✗ WRONG (no error, but help will be missing): - src/main/resources/org/projectcontinuum/feature/demo/WordCounterNodeModel.doc.md - src/main/resources/demo/node/WordCounterNodeModel.doc.md +src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md ``` -**Path construction rule**: Replace `.` with `/` in your package name, then append `/node/` and your class name + `.doc.md`. +To build the path, take the class's full name, replace each `.` with `/` and add `.doc.md`. The `node` folder is part of the package, not an extra segment. -If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. There's no build error to warn you. +If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*, and the build doesn't warn you. A good help page has four parts, as in the template's Hello World page: what the node does, a **Configuration** table, a **Ports** table, and a small **Example** with input and output tables. diff --git a/docs/contributing/create-new-nodes/step-5-test-and-run.md b/docs/contributing/create-new-nodes/step-5-test-and-run.md index 9a47e2e..25961da 100644 --- a/docs/contributing/create-new-nodes/step-5-test-and-run.md +++ b/docs/contributing/create-new-nodes/step-5-test-and-run.md @@ -45,47 +45,7 @@ Ask the worker which nodes it serves: curl http://localhost:8090/api/v1/node-repo ``` -Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. Work through these checks in order (most common first): - -### Pre-Flight Checklist - Node Not Appearing - -This is a **silent failure**. The build passes, the worker runs, but your node doesn't appear. - -- [ ] **Check the module is in the worker** - ```bash - grep "implementation(project" worker/build.gradle.kts - ``` - Should contain: `implementation(project(":features:"))` - - **If missing**: Add it and rebuild. - -- [ ] **Check the AutoConfigure class is named in the .imports file** - ```bash - cat worker/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports - ``` - Should contain exactly: `.AutoConfigure` - - **If wrong**: Fix the class name and rebuild. - -- [ ] **Check AutoConfigure scans your package** - Look at `features//src/main/kotlin//AutoConfigure.kt`: - ```kotlin - @ComponentScan(basePackages = [""]) - ``` - Should include your package. Your node class must be in this package or a subpackage. - - **If wrong**: Update `basePackages` and rebuild. - -- [ ] **Check your node class has the annotation** - Look at `features//src/main/kotlin//node/NodeModel.kt`: - ```kotlin - @ContinuumNode - class YourNodeModel(...) : ProcessNodeModel() { ... } - ``` - - **If missing**: Add `@ContinuumNode` and rebuild. - -If all four checks pass, restart the worker and try again. +Your **Word Counter** should be in the response. If it isn't, the build passed but the worker didn't find your node. Follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). It covers the four usual causes: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class, `@ComponentScan` doesn't cover your package, or the class is missing `@ContinuumNode`. ## 4. Run it in the Workbench @@ -93,33 +53,9 @@ If all four checks pass, restart the worker and try again. 2. Add a table source that has a `text` column, such as **Create Table**, and connect it to Word Counter. 3. Open the Word Counter settings to see the form you defined, then run the workflow. 4. Click the output port. Every row has a new `word_count` column. +5. Open the node's help page in the Workbench. It should show your `.doc.md` content. If it reads "Documentation not found", see [Step 4](./step-4-write-your-node.md#2-the-help-page). -### Verify the Help Page - -While in the Workbench, look for a help icon or panel next to your node. It should show documentation from your `.doc.md` file. If it says "Documentation not found", the file path doesn't match. See [Step 4 - The help page](./step-4-write-your-node.md#2-the-help-page). - -## 5. Configuration reference for local testing - -When running locally (`./gradlew :worker:bootRun`), these values are used by default. You can override them with environment variables when deploying elsewhere: - -| Variable | Local default | What it controls | -|----------|---------------|------------------| -| `CONTINUUM_NODE_TASK_QUEUE` | from `application.yaml` | This worker's Temporal task queue | -| `TEMPORAL_SERVER_ADDRESS` | `localhost:7233` | Temporal frontend address | -| `TEMPORAL_NAMESPACE` | `default` | Temporal namespace | -| `CONTINUUM_API_SERVER_BASE_URL` | `http://localhost:8080` | API server for node registration | -| `CONTINUUM_KAFKA_MAIN_BROKER_LIST` | `localhost:39092,39093,39094` | Kafka brokers | -| `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Avro schema registry | -| `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage endpoint | -| `CONTINUUM_MINIO_USERNAME` | `minioadmin` | MinIO credentials | -| `CONTINUUM_MINIO_PASSWORD` | `minioadmin` | MinIO credentials | -| `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local data cache directory | -| `SERVER_PORT` | `8090` | Worker HTTP port (keep 8090 locally; 8080 is for API server) | - -For nodes that call `getCredential()`, also set: -| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Credentials service | - -Locally, you don't need to change these. The defaults work with the local stack from Step 1. +Locally you don't need to set any environment variables: the worker's defaults match the local stack. When you deploy elsewhere, see the [worker configuration reference](./step-6-ship-it.md#worker-configuration-reference). You've now changed the template into your own working worker. diff --git a/docs/contributing/create-new-nodes/step-6-ship-it.md b/docs/contributing/create-new-nodes/step-6-ship-it.md index 030d806..096ea14 100644 --- a/docs/contributing/create-new-nodes/step-6-ship-it.md +++ b/docs/contributing/create-new-nodes/step-6-ship-it.md @@ -30,10 +30,8 @@ flowchart TB H --> K["Helm chart to gh-pages"] ``` -:::warning[Key Step: Create a GitHub Release] -After merging to main, you must go to the GitHub UI and create a release. Don't just tag the commit or push a version. **Go to:** Repository → Releases → Create a new release - -This triggers the `on-release.yml` and `release.yml` workflows that publish your artifacts. +:::warning[Publish a GitHub Release] +After merging to `main`, create a release in the GitHub UI. That is what starts the publishing workflows. ::: ## 1. Bump the version @@ -63,11 +61,11 @@ appVersion: "0.0.2" # Must match gradle.properties | `validate-versions.yml` | PR | Checks the version rules above | | `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | | `build-module.yml` | Manual | Build one module, optionally publish it | -| `on-release.yml` | ⭐ **GitHub release published** | Libraries → Maven Central, worker → Docker Hub | -| `release.yml` | ⭐ **GitHub release published** | Package the Helm chart and update the `gh-pages` index | +| `on-release.yml` | GitHub release published | Libraries → Maven Central, worker → Docker Hub | +| `release.yml` | GitHub release published | Package the Helm chart and update the `gh-pages` index | -:::info[Workflows are triggered by Release, not by Tag or Push] -The workflows that publish your artifacts (`on-release.yml` and `release.yml`) run when you **publish a GitHub Release**. They don't run on tags or commits. You must explicitly create a release in the GitHub UI. +:::info[Workflows are triggered by a published release] +`on-release.yml` and `release.yml` run when you **publish a GitHub Release** (Repository → Releases → Create a new release). Pushing a tag or merging to `main` doesn't trigger them. ::: ## 3. Add repository secrets diff --git a/docs/contributing/create-new-nodes/troubleshooting.md b/docs/contributing/create-new-nodes/troubleshooting.md index 9679276..22e6950 100644 --- a/docs/contributing/create-new-nodes/troubleshooting.md +++ b/docs/contributing/create-new-nodes/troubleshooting.md @@ -8,84 +8,37 @@ title: Troubleshooting ## My node doesn't show up in the Workbench -This is the most common issue. The build passes but your node isn't in the palette. Work through this checklist in order. +The build passes but your node isn't in the palette. Work down this list in order. -### Quick Diagnostic - -First, verify the worker is running and check the node repository: - -```bash -# Is the worker healthy? -curl http://localhost:8090/actuator/health - -# Does it have any nodes registered? -curl http://localhost:8090/api/v1/node-repo -``` - -If you don't see your node in the JSON response, continue below. - -### Pre-Flight Checklist (Most Common Issues) - -These four things are the most common causes. Check all four: - -1. **Module is listed in worker/build.gradle.kts** +1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy. If it isn't in the response, continue with the checks below. +2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: ```bash grep "implementation(project" worker/build.gradle.kts ``` - Should show: `implementation(project(":features:"))` - - **If missing**: Add it, rebuild, and restart the worker. - -2. **.imports file names the correct AutoConfigure class** +3. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: ```bash - cat worker/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports - ``` - Should show exactly: `.AutoConfigure` - - **If wrong**: Fix the class name, rebuild, and restart. - -3. **AutoConfigure.kt has correct @ComponentScan** - Look at `features//src/main/kotlin//AutoConfigure.kt`: - ```kotlin - @ComponentScan(basePackages = [""]) + cat features//src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports ``` - Your node must be in this package or a subpackage. - - **If wrong**: Update basePackages, rebuild, and restart. - -4. **Your node class has @ContinuumNode annotation** - ```kotlin - @ContinuumNode - class YourNodeModel(...) : ProcessNodeModel() { ... } - ``` - - **If missing**: Add the annotation, rebuild, and restart. - -:::tip[After fixing any of these, don't forget to restart the worker] -Changes in Gradle files and annotations require a rebuild and worker restart. Just reloading the browser won't work. -::: - -### Still Not Appearing? + It must contain exactly `.AutoConfigure`. +4. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt`, `basePackages` must include your node's package. The node class must be in that package or below. +5. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. The build fails without it, so if `./gradlew build` passed, this is rarely the cause. -If all four items above are correct, try these additional checks: +After fixing any of these, rebuild and restart the worker. Reloading the browser isn't enough. -- **Is your node in the right package?** It must be in a package ending in `.node`, and under the package scanned by `AutoConfigure`. -- **Did you run `./gradlew build`?** The build validates annotations and can catch errors earlier. -- **Are there compilation errors?** Check the build output for Jackson or other import errors. -- **Try restarting the whole stack**: Stop the worker, kill the containers, restart them, and start the worker again. +Still not appearing? Check that the node's package ends in `.node`, that the build output has no compilation errors, and that the local stack is healthy (`docker compose ps` in `docker/`). As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. ## Errors | Symptom | Cause and fix | |---------|---------------| | `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | -| `Unresolved reference 'databind'` / `'ObjectMapper'` | **Jackson 2 imports instead of Jackson 3.** Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. Not `com.fasterxml.jackson.*`. | +| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`, not `com.fasterxml.jackson.*`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | | `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | -| **A node fails at random, or runs on the wrong worker** | **Several workers share a task queue** (critical issue). Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. Search other continuum workers before picking a name. | -| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (not String, Int, Long, Float, Double, Boolean, List, Map, or SVG). Convert to one of these types first, or omit the key instead of using null. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | -| **Help page reads "Documentation not found"** | **The `.doc.md` file path doesn't match the node's package and class name exactly.** Path must be: `src/main/resources//node/.doc.md`. See [Step 4 - The help page](./step-4-write-your-node.md#2-the-help-page). | +| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Temporal gives work to whichever worker polls first, including one that doesn't have the node, and nothing warns you. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | +| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (String, Int, Long, Float, Double, Boolean, List, Map or SVG). Convert it, or leave the key out instead of using `null`. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `org.example.node.MyNodeModel` it is `src/main/resources/org/example/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | | Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | -| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the **same value**. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | -| **Saved workflows break after a rename** | **You renamed or moved a node class. The full class name is the node's identity in saved workflows. This is permanent.** Don't rename classes after shipping. | +| PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows, so don't rename classes after shipping. | From bb0c4be5b6bc5df510563cb61cd8316f839daa6c Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 16:05:00 +0530 Subject: [PATCH 4/6] CONTNM-137: fix some refs --- .../step-2-tour-the-template.md | 8 +- .../create-new-nodes/step-3-make-it-yours.md | 22 ++++-- .../step-4-write-your-node.md | 30 ++++++-- .../create-new-nodes/step-5-test-and-run.md | 9 +-- .../create-new-nodes/step-6-ship-it.md | 73 +++++++++++++------ .../create-new-nodes/troubleshooting.md | 33 ++++++--- 6 files changed, 124 insertions(+), 51 deletions(-) diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md index 83a3b07..52640c7 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md @@ -83,15 +83,17 @@ These three live side by side in each feature module and share a name: ### Files that connect your nodes to the platform -If you get one of these wrong, the build still passes but **the worker starts with no nodes**. These are the most common reasons a new node doesn't appear. +If you get one of the first three wrong, the build still passes but **the worker starts with no nodes**, and nothing in the build output tells you why. These are the most common reasons a new node doesn't appear. | File | Why it matters | |------|----------------| -| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. | -| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. | +| `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. If `basePackages` doesn't cover your node's package, the node isn't found. | +| `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. If the file is missing or names the wrong class, Spring doesn't load your module. | | `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | | `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | +If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). + ### Files that must agree with each other | Setting | Where it lives | Rule | diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md index e46fbfd..eb241d7 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md @@ -13,13 +13,13 @@ title: "Step 3: Make it yours" The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. -The examples below use these placeholders. Pick your values first: +Pick your values first, and check the other Continuum repositories to make sure the names aren't already in use: -| Placeholder | Example | Used for | -|-------------|---------|----------| -| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | -| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | -| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique.** | +| Placeholder | Example | Used for | Changing it later | +|-------------|---------|----------|-------------------| +| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Possible, but you repeat this whole step. | +| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | +| `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique across all workers in your Continuum instance.** | Change it in `application.yaml` and the chart together. | ## Checklist @@ -103,8 +103,18 @@ Then confirm nothing broke: If you changed the chart, also run `helm lint charts/`. +### Before you move on + +- [ ] The module folder, the `include(...)` line in `settings.gradle.kts` and the `implementation(project(...))` line in `worker/build.gradle.kts` all use the same module name. +- [ ] The `.imports` file names your real `AutoConfigure` class. +- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml` (if you updated the chart). +- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml` (if you updated the chart). +- [ ] The leftover grep above prints nothing. +- [ ] `./gradlew build` passes, and `helm lint charts/` passes if you changed the chart. + :::info[What you can skip for now] You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. ::: Next: [write your node](./step-4-write-your-node.md). + diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md index 37c4c4b..7e001cb 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md @@ -157,13 +157,22 @@ Break one of these and the build fails, the node doesn't load, or workflows brea | Rule | Why | |------|-----| -| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it. | +| Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it (`validateContinuumNodeAnnotations`). | | Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | | Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | | Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | -| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.databind` won't compile. | +| Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.*` (Jackson 2) won't compile. | | Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | +### Ports + +`inputPorts` and `outputPorts` are maps: + +- The **key** (for example `"data"`) is the port ID you use in `execute()` to read or write data. +- The **value** is a `ContinuumWorkflowModel.NodePort` with a `name` (shown in the Workbench) and a `contentType`. + +Table ports use `APPLICATION_OCTET_STREAM_VALUE`, as in the running example. The template's example nodes do the same. + ### Settings and validation - `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. @@ -176,7 +185,7 @@ Break one of these and the build fails, the node doesn't load, or workflows brea - `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. - Wrap both in `.use { }`. The output file is only complete once the writer is closed. -Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Convert other types first (for example `toString()` on a `LocalDate`), and leave a key out instead of storing `null`. +Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Leave a key out instead of storing `null`. | Kotlin type | Stored as | |-------------|-----------| @@ -187,9 +196,16 @@ Cell values must be one of these types, and never `null`. Anything else makes `w | `List<*>`, `Map<*, *>` | `application/json` | | SVG `org.w3c.dom.Document` | `image/svg+xml` | +Convert anything else first. For example, call `toString()` on a `LocalDate`, and convert a `BigDecimal` to a `Double` or a `String`. + ### Errors, retries and progress -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default. Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as missing settings or an unconnected port. Empty strings are fine for `workflowId` and `nodeId`. +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as: +- Missing or invalid settings (user error) +- An unconnected input port +- Invalid input data that can't be recovered from + +Empty strings are fine for `workflowId` and `nodeId` in the exception. Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. @@ -197,13 +213,15 @@ Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. -The path must match the node's package and class name exactly: +The path must match the node's package and class name exactly. For the class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`, the file is: ```text src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md ``` -If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*. +To build the path, take the class's full name, replace each `.` with `/` and add `.doc.md`. The `node` folder is part of the package, not an extra segment. + +If the file is missing or misplaced, the node still works, but its help page reads *"Documentation not found for WordCounterNodeModel"*, and the build doesn't warn you. A good help page has four parts, as in the template's Hello World page: what the node does, a **Configuration** table, a **Ports** table, and a small **Example** with input and output tables. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md index 92851c8..25961da 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md @@ -45,11 +45,7 @@ Ask the worker which nodes it serves: curl http://localhost:8090/api/v1/node-repo ``` -Your **Word Counter** should be in the response. If it isn't, the worker didn't find your node. The usual causes are, in order: - -1. The `.imports` file names the wrong class, or `AutoConfigure`'s `basePackages` doesn't cover your package ([Step 3](./step-3-make-it-yours.md#2-the-feature-module)). -2. `worker/build.gradle.kts` doesn't list your module. -3. The class is missing `@ContinuumNode`. +Your **Word Counter** should be in the response. If it isn't, the build passed but the worker didn't find your node. Follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). It covers the four usual causes: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class, `@ComponentScan` doesn't cover your package, or the class is missing `@ContinuumNode`. ## 4. Run it in the Workbench @@ -57,6 +53,9 @@ Your **Word Counter** should be in the response. If it isn't, the worker didn't 2. Add a table source that has a `text` column, such as **Create Table**, and connect it to Word Counter. 3. Open the Word Counter settings to see the form you defined, then run the workflow. 4. Click the output port. Every row has a new `word_count` column. +5. Open the node's help page in the Workbench. It should show your `.doc.md` content. If it reads "Documentation not found", see [Step 4](./step-4-write-your-node.md#2-the-help-page). + +Locally you don't need to set any environment variables: the worker's defaults match the local stack. When you deploy elsewhere, see the [worker configuration reference](./step-6-ship-it.md#worker-configuration-reference). You've now changed the template into your own working worker. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md index 94bfff7..096ea14 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md @@ -17,18 +17,42 @@ Shipping is mostly already set up in the template. This page explains what each ```mermaid flowchart TB - A["Bump featureVersion"] --> B["Open PR: CI checks run"] --> D["Merge to main"] --> E["Publish a GitHub release"] - E --> F["Feature modules to Maven Central
on-release.yml"] - E --> G["Worker image to Docker Hub
on-release.yml"] - E --> H["Helm chart to gh-pages
release.yml"] + A["Bump featureVersion in gradle.properties
Update appVersion in Chart.yaml
(must match)"] --> B["Open PR: CI checks run"] + B --> C{Pass CI?} + C -->|No| D["Fix and push again"] + D --> B + C -->|Yes| E["Merge to main"] + E --> F["Go to GitHub Releases page"] + F --> G["Click 'Create a new release'"] + G --> H["GitHub release triggers workflows"] + H --> I["Feature modules to Maven Central"] + H --> J["Worker image to Docker Hub"] + H --> K["Helm chart to gh-pages"] ``` +:::warning[Publish a GitHub Release] +After merging to `main`, create a release in the GitHub UI. That is what starts the publishing workflows. +::: + ## 1. Bump the version -Every change under `features/` or `worker/` needs a new `featureVersion` in `gradle.properties`, and the chart's `appVersion` in `charts//Chart.yaml` must be set to the same value. +Every change under `features/` or `worker/` needs: +1. A new `featureVersion` in `gradle.properties` +2. The chart's `appVersion` in `charts//Chart.yaml` set to the **same value** CI enforces both on every pull request (`validate-versions.yml`). If your PR fails with "does not match featureVersion" or "featureVersion must be bumped", this is why. +**Example:** +```properties +# gradle.properties +featureVersion=0.0.2 +``` + +```yaml +# charts//Chart.yaml +appVersion: "0.0.2" # Must match gradle.properties +``` + ## 2. What CI runs | Workflow | When | What it does | @@ -37,38 +61,45 @@ CI enforces both on every pull request (`validate-versions.yml`). If your PR fai | `validate-versions.yml` | PR | Checks the version rules above | | `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | | `build-module.yml` | Manual | Build one module, optionally publish it | -| `on-release.yml` | GitHub release | Libraries → Maven Central, worker → Docker Hub | -| `release.yml` | GitHub release | Package the Helm chart and update the `gh-pages` index | +| `on-release.yml` | GitHub release published | Libraries → Maven Central, worker → Docker Hub | +| `release.yml` | GitHub release published | Package the Helm chart and update the `gh-pages` index | + +:::info[Workflows are triggered by a published release] +`on-release.yml` and `release.yml` run when you **publish a GitHub Release** (Repository → Releases → Create a new release). Pushing a tag or merging to `main` doesn't trigger them. +::: ## 3. Add repository secrets The release workflows read these from your repository's **Settings → Secrets and variables → Actions**: -| Secret | Used for | -|--------|----------| -| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | -| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | -| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | +| Secret | Used for | Required? | +|--------|----------|-----------| +| `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | If publishing to Maven Central | +| `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | If publishing to Maven Central | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, always needed | :::tip[Not publishing libraries?] If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. + +You still need Docker Hub secrets to publish the worker image. ::: -## 4. Deploy to Kubernetes +## 4. Verify before deployment + +Before installing the chart to Kubernetes, verify these critical synchronization points: -The chart installs next to `continuum-infra` and `continuum-platform` in the same namespace: +- [ ] `taskQueue` in `charts//values.yaml` matches `node-task-queue` in `application.yaml` +- [ ] `taskQueue` is globally unique (search other workers) +- [ ] `image.repository` in values.yaml matches what your release pushes to Docker Hub +- [ ] The `continuum.infra.*` and `apiServer` hosts match the release names of other Continuum services + +Then install: ```bash helm install ./charts/ -n continuum ``` -Check these before you install: - -- `taskQueue` in `values.yaml` matches `node-task-queue` in `application.yaml`, and is unique. -- `image.repository` is the image your release pushes. -- The `continuum.infra.*` and `apiServer` hosts match the release names you used for `continuum-infra` and `continuum-platform`. - -See [Deployment](../../deployment/helm-charts.md) for the full setup. +See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup. ## Worker configuration reference diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md index c9bad42..22e6950 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md @@ -8,24 +8,37 @@ title: Troubleshooting ## My node doesn't show up in the Workbench -Work down this list. Each item is a more common cause than the next. +The build passes but your node isn't in the palette. Work down this list in order. -1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the problem is on the Workbench or platform side; refresh the page and check the local stack is healthy. -2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`. -3. **Does Spring find the module?** The `.imports` file must contain the full name of your `AutoConfigure` class, and `AutoConfigure`'s `@ComponentScan(basePackages = ...)` must cover your node's package. See [Step 3](./step-3-make-it-yours.md#2-the-feature-module). -4. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. +1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy. If it isn't in the response, continue with the checks below. +2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: + ```bash + grep "implementation(project" worker/build.gradle.kts + ``` +3. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: + ```bash + cat features//src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports + ``` + It must contain exactly `.AutoConfigure`. +4. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt`, `basePackages` must include your node's package. The node class must be in that package or below. +5. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. The build fails without it, so if `./gradlew build` passed, this is rarely the cause. + +After fixing any of these, rebuild and restart the worker. Reloading the browser isn't enough. + +Still not appearing? Check that the node's package ends in `.node`, that the build output has no compilation errors, and that the local stack is healthy (`docker compose ps` in `docker/`). As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. ## Errors | Symptom | Cause and fix | |---------|---------------| | `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | -| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`. | +| `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`, not `com.fasterxml.jackson.*`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | | `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | -| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | -| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's package and class name. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| A node fails at random, or runs on the wrong worker | Several workers share a task queue. Temporal gives work to whichever worker polls first, including one that doesn't have the node, and nothing warns you. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | +| `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (String, Int, Long, Float, Double, Boolean, List, Map or SVG). Convert it, or leave the key out instead of using `null`. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `org.example.node.MyNodeModel` it is `src/main/resources/org/example/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | | Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | | PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | -| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows. | +| Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows, so don't rename classes after shipping. | + From 621306a8e10546fb4427c525ae44c667e4728418 Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 17:24:02 +0530 Subject: [PATCH 5/6] CONTNM-137: add java example in docs --- .../contributing/create-new-nodes/overview.md | 12 +- docs/contributing/create-new-nodes/recipes.md | 276 +++++++++++++++ .../create-new-nodes/step-1-clone-and-run.md | 6 +- .../step-2-tour-the-template.md | 19 +- .../create-new-nodes/step-3-make-it-yours.md | 190 ++++++++-- .../step-4-write-your-node.md | 326 ++++++++++++++++-- .../create-new-nodes/step-5-test-and-run.md | 13 +- .../create-new-nodes/step-6-ship-it.md | 102 +++++- .../create-new-nodes/troubleshooting.md | 43 ++- docs/contributing/feature-template.md | 2 +- docusaurus.config.ts | 2 +- .../contributing/create-new-nodes/overview.md | 12 +- .../contributing/create-new-nodes/recipes.md | 276 +++++++++++++++ .../create-new-nodes/step-1-clone-and-run.md | 6 +- .../step-2-tour-the-template.md | 19 +- .../create-new-nodes/step-3-make-it-yours.md | 190 ++++++++-- .../step-4-write-your-node.md | 326 ++++++++++++++++-- .../create-new-nodes/step-5-test-and-run.md | 13 +- .../create-new-nodes/step-6-ship-it.md | 102 +++++- .../create-new-nodes/troubleshooting.md | 43 ++- .../contributing/feature-template.md | 2 +- 21 files changed, 1761 insertions(+), 219 deletions(-) create mode 100644 docs/contributing/create-new-nodes/recipes.md create mode 100644 versioned_docs/version-0.0.20/contributing/create-new-nodes/recipes.md diff --git a/docs/contributing/create-new-nodes/overview.md b/docs/contributing/create-new-nodes/overview.md index 00cfffd..f197fff 100644 --- a/docs/contributing/create-new-nodes/overview.md +++ b/docs/contributing/create-new-nodes/overview.md @@ -23,7 +23,7 @@ Start from the **`continuum-feature-template`** repository, rename it, replace i A **node** is a block on the Workbench canvas that reads tables, does something and writes tables. Nodes live in a **feature worker**, a small Spring Boot app that registers its nodes with the platform at startup. -You don't build a worker from scratch. The template is already a complete, working worker with two example nodes, a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. +You don't build a worker from scratch. The template is already a complete, working worker with two example nodes (one Kotlin, one Java), a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. ```mermaid flowchart LR @@ -34,11 +34,12 @@ flowchart LR | Requirement | Notes | |-------------|-------| -| JDK 21 | Eclipse Temurin recommended. | +| JDK 21 | Eclipse Temurin recommended. Check with `java -version`. | | Docker and Compose | Runs the local Continuum stack, about 8 GB of RAM. | | Some Kotlin or Java | You don't need to know Temporal, Kafka or Spring internals. | +| A GitHub account | The template is used from GitHub, and the release steps run on GitHub Actions. | -You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. +You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. To publish your work you also need Docker Hub (or another registry) credentials, and optionally a Maven Central account; [Step 6](./step-6-ship-it.md) covers both. ## The steps @@ -47,16 +48,19 @@ You don't need a GitHub token, and you don't need to install Gradle: the reposit 1. [Clone the template and run it](./step-1-clone-and-run.md): see the example nodes working before you change anything. 2. [Tour the template](./step-2-tour-the-template.md): which files you write, which you rename and which you leave alone. 3. [Make it yours](./step-3-make-it-yours.md): a checklist for renaming the project, packages, worker and chart. -4. [Write your node](./step-4-write-your-node.md): the node class, its help page and its unit test. +4. [Write your node](./step-4-write-your-node.md): the node class (Kotlin and Java), its help page and its unit test. 5. [Test and run your node](./step-5-test-and-run.md): build, run the worker and use your node in the Workbench. 6. [Ship it](./step-6-ship-it.md): versions, CI, release and Kubernetes. +After the six steps, [More node recipes](./recipes.md) covers adding more nodes, source nodes, credentials, retries, extra libraries, logging and debugging. + ## Where to look when something breaks - Your node doesn't appear in the Workbench: [Troubleshooting](./troubleshooting.md). - The platform's side of registration: [Node Model & Feature Registration](../../architecture/node-model.md). +- A full list of errors and fixes, from the build to Kubernetes: [Troubleshooting](./troubleshooting.md). - The template's own README and `AGENTS.md` list its commands and rules. :::info[Versions] diff --git a/docs/contributing/create-new-nodes/recipes.md b/docs/contributing/create-new-nodes/recipes.md new file mode 100644 index 0000000..0f779a4 --- /dev/null +++ b/docs/contributing/create-new-nodes/recipes.md @@ -0,0 +1,276 @@ +--- +sidebar_position: 8 +sidebar_label: "More node recipes" +title: "More node recipes" +--- + +# More node recipes + + + After Step 5 + Kotlin examples + + +[Step 4](./step-4-write-your-node.md) builds one process node. This page covers what you reach for next. The Kotlin code on this page was compiled and its tests were run against platform `0.0.20`. Java versions follow the same shape as the Java Word Counter in Step 4, and the notes below say where the API differs. + +## Add a second node + +You don't need a new module for every node. Add another class to the same package: + +1. Create `/node/MyOtherNodeModel.kt` next to your first node, annotated with `@ContinuumNode`. +2. Add `MyOtherNodeModel.doc.md` in the matching resources folder. +3. Add a test. +4. Bump `featureVersion` and the chart's `appVersion` before you ship ([Step 6](./step-6-ship-it.md#1-bump-the-version)). + +That's all. `AutoConfigure` already scans your whole package, so there is nothing to register. Rebuild and restart the worker; it logs every node it found: + +```text +Registered process nodes: [com.acme.demo.node.WordCounterNodeModel, com.acme.demo.node.MyOtherNodeModel] +Registered trigger nodes: [...] +``` + +Create a **second module** only when you want to publish some nodes as a separate library, or keep unrelated nodes apart. A new module needs a folder under `features/`, an `include(...)` in `settings.gradle.kts`, an `implementation(project(...))` in `worker/build.gradle.kts`, its own `AutoConfigure` and `.imports` file, and entries in the two workflow files. [Step 2](./step-2-tour-the-template.md#files-that-must-agree-with-each-other) lists everything that must agree. + +## A source node with no inputs + +A node that creates data from nothing (a generator, a file reader, an API poll) extends `TriggerNodeModel` instead of `ProcessNodeModel`. It has no `inputPorts`, and `execute()` has no `inputs` parameter: + +```kotlin +package com.acme.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.TriggerNodeModel +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE + +@ContinuumNode +class NumberGeneratorNodeModel : TriggerNodeModel() { + + final override val outputPorts = mapOf( + "output" to ContinuumWorkflowModel.NodePort(name = "Numbers", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + + override val categories = listOf("Demo") + + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "Number Generator", + subTitle = "Create a table of numbers", + description = "Creates a table with a number column and its square", + outputs = outputPorts, + properties = mapOf("count" to 10), + propertiesSchema = mapOf( + "type" to "object", + "properties" to mapOf("count" to mapOf("type" to "integer", "title" to "Row Count", "minimum" to 1)), + "required" to listOf("count") + ), + propertiesUISchema = mapOf( + "type" to "VerticalLayout", + "elements" to listOf(mapOf("type" to "Control", "scope" to "#/properties/count")) + ) + ) + + override fun execute(properties: Map?, nodeOutputWriter: NodeOutputWriter) { + val count = (properties?.get("count") as Number?)?.toInt() ?: 10 + + nodeOutputWriter.createOutputPortWriter("output").use { writer -> + for (n in 0 until count) { + writer.write(n.toLong(), mapOf("n" to n, "square" to n * n)) + } + } + } +} +``` + +Everything else from Step 4 applies: the `.doc.md` help page, the package rule, the row types and the test approach. In a test you call `execute(properties, outputWriter)` with just two arguments. + +This example builds its schemas with `mapOf(...)` instead of parsing JSON strings. Both styles work; `mapOf` needs no `ObjectMapper`. + +## Use a credential + +Nodes that call an API, a database or a cloud service shouldn't take secrets as plain settings. Store the secret as a **credential** in the platform, let the user pick it in the node's form, and read it in `execute()`. + +There are three pieces: + +1. The settings hold only the credential's **name**. +2. The UI schema marks that control with `options.format = "credential"`, so the Workbench shows a credential picker. +3. `execute()` takes an extra `ExecutionContext` parameter and calls `getCredential`. + +```kotlin +package com.acme.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.context.ExecutionContext +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.ProcessNodeModel +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE + +@ContinuumNode +class ApiLookupNodeModel : ProcessNodeModel() { + + final override val inputPorts = mapOf( + "input" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + final override val outputPorts = mapOf( + "output" to ContinuumWorkflowModel.NodePort(name = "Output Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + override val categories = listOf("Demo") + + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "API Lookup", + description = "Calls an API with a stored credential", + inputs = inputPorts, + outputs = outputPorts, + properties = mapOf("credential" to ""), + propertiesSchema = mapOf( + "type" to "object", + "properties" to mapOf("credential" to mapOf("type" to "string", "title" to "Credential")), + "required" to listOf("credential") + ), + propertiesUISchema = mapOf( + "type" to "VerticalLayout", + "elements" to listOf( + mapOf( + "type" to "Control", + "scope" to "#/properties/credential", + "options" to mapOf("format" to "credential", "credentialType" to "GENERIC") + ) + ) + ) + ) + + // The shape of the credential's key-value data + data class ApiKey(val key: String) + + override fun execute( + properties: Map?, + inputs: Map, + nodeOutputWriter: NodeOutputWriter, + nodeProgressCallback: NodeProgressCallback, + executionContext: ExecutionContext + ) { + val name = properties?.get("credential") as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "No credential selected") + val apiKey = executionContext.getCredential(name) + + nodeOutputWriter.createOutputPortWriter("output").use { writer -> + writer.write(0L, mapOf("key_length" to apiKey.key.length)) + } + } +} +``` + +The example only writes the length of the key. **Never write secrets to an output port or a log.** In your own node, use the key to call the API and write the response. + +Things to know: + +- `getCredential` throws `CredentialsNotFoundException` if no credential has that name. Decide whether that should be retried; usually it is a user error and should become a non-retriable `NodeRuntimeException`. +- In Java, call `executionContext.getCredential(name, ApiKey.class)`, with `ApiKey` as a class or record whose fields match the credential's keys. The `execute` override takes the same five parameters. +- Overriding the five-parameter `execute` replaces the four-parameter one. Don't override both. +- The worker reads credentials from the credentials server at `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` (default `http://localhost:8083`). The template's local Docker stack doesn't include one, so you can't try this node end to end locally unless you run the credentials server yourself. Test it with a fake fetcher instead, as below. +- **On Kubernetes, set that variable in your chart.** The `continuum-platform` chart deploys the credentials server, but the template's `deployment.yaml` doesn't pass its address to your worker, so a credential node would look for `localhost:8083` and fail. Add this to the `env:` list in `charts//templates/deployment.yaml`, next to `CONTINUUM_API_SERVER_BASE_URL`, and adjust the host if you installed `continuum-platform` under another release name (the service is `-credentials-server`, port 8080): + + ```yaml + - name: CONTINUUM_CREDENTIALS_SERVER_BASE_URL + value: "http://continuum-platform-credentials-server:8080" + ``` +- For the platform side (how credentials are stored and fetched), see [Credentials in the node model](../../architecture/node-model.md#credentials). + +Test it by giving `ExecutionContext` a fake `CredentialFetcher`: + +```kotlin +package com.acme.demo.node + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.argumentCaptor +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever +import org.projectcontinuum.core.commons.context.CredentialFetcher +import org.projectcontinuum.core.commons.context.ExecutionContext +import org.projectcontinuum.core.commons.utils.NodeOutputWriter + +class ApiLookupNodeModelTest { + @Test + fun `reads the selected credential`() { + val outputWriter = mock() + val portWriter = mock() + whenever(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter) + val context = ExecutionContext( + ownerId = "test-user", + credentialFetcher = CredentialFetcher { name -> if (name == "my-key") mapOf("key" to "abc123") else null } + ) + + ApiLookupNodeModel().execute(mapOf("credential" to "my-key"), emptyMap(), outputWriter, mock(), context) + + val row = argumentCaptor>() + verify(portWriter).write(any(), row.capture()) + assertEquals(6, row.firstValue["key_length"]) + } +} +``` + +## Change a node's retry behaviour + +By default a failing node is retried with the workflow's retry policy. To give one node its own policy, set `retryOptions` in its metadata: + +```kotlin +override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "API Lookup", + description = "Calls an API with a stored credential", + retryOptions = ContinuumWorkflowModel.RetryOptionsConfig(maximumAttempts = 3, initialIntervalSeconds = 5), + // … ports, properties and schemas as before +) +``` + +`RetryOptionsConfig` has five optional fields: `initialIntervalSeconds`, `backoffCoefficient`, `maximumIntervalSeconds`, `maximumAttempts` and `doNotRetry` (a list of exception type names that must never be retried). Leave a field out to keep the default. In Java, pass `null` for the `retryOptions` argument of `NodeData` to keep the workflow default, as the Word Counter does. + +A `NodeRuntimeException` with `isRetriable = false` is never retried, whatever the policy says. + +## Add a library + +The Continuum plugins already give you Spring, Jackson 3, the test libraries and SLF4J. Add anything else to the feature module's own `build.gradle.kts`, not the worker's: + +```kotlin +dependencies { + implementation("org.apache.commons:commons-text:1.12.0") +} +``` + +The worker picks it up through `implementation(project(":features:"))`. Don't add Jackson 2 artifacts; they clash with the platform's Jackson 3. + +## Log from a node + +Use SLF4J. The plugins put it on the classpath, so no dependency is needed: + +```kotlin +import org.slf4j.LoggerFactory + +private val logger = LoggerFactory.getLogger(WordCounterNodeModel::class.java) + +// inside execute(): +logger.info("Counted words in {} rows", rowNumber) +``` + +The template's `application.yaml` sets the root log level to `error` and your package to `debug`, so your `info` and `debug` lines show up in the worker's console while other libraries stay quiet. Don't log row contents or credentials. + +## Debug a node + +- **Run the worker from your IDE.** Start `App.kt` in the `worker` module with the debugger and set breakpoints in your node. The worker defaults match the local stack, so no extra configuration is needed. +- **Or attach to Gradle.** `./gradlew :worker:bootRun --debug-jvm` waits for a debugger on port 5005. +- **Run a workflow** in the Workbench to trigger the node. A breakpoint in `execute()` pauses it. Temporal may time the activity out if you stay paused for a long time, so step through quickly. +- Prefer a **unit test** when you can: it reproduces most logic bugs without Docker. Add a failing test, fix the code, keep the test. + +Next: if something doesn't work, see [Troubleshooting](./troubleshooting.md). diff --git a/docs/contributing/create-new-nodes/step-1-clone-and-run.md b/docs/contributing/create-new-nodes/step-1-clone-and-run.md index 1bb1f20..64e91ff 100644 --- a/docs/contributing/create-new-nodes/step-1-clone-and-run.md +++ b/docs/contributing/create-new-nodes/step-1-clone-and-run.md @@ -47,7 +47,11 @@ From the repository root: ./gradlew :worker:bootRun ``` -The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. +The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. Wait for these lines in its output: + +```text +Registered process nodes: [org.projectcontinuum.feature.example.node.HelloWorldNodeModel, org.projectcontinuum.feature.example.java.node.HelloJavaNodeModel] +``` ## 5. See your nodes in the Workbench diff --git a/docs/contributing/create-new-nodes/step-2-tour-the-template.md b/docs/contributing/create-new-nodes/step-2-tour-the-template.md index 52640c7..23ee2c9 100644 --- a/docs/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/docs/contributing/create-new-nodes/step-2-tour-the-template.md @@ -15,7 +15,7 @@ The template has about 40 files, but you will only write code in a handful of th ## The big picture -Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. +Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. The template ships two example modules, one in Kotlin and one in Java. You keep the one you write in and delete the other in [Step 3](./step-3-make-it-yours.md). ```mermaid flowchart LR @@ -56,7 +56,7 @@ continuum-feature-template/ │ │ └── …/node/HelloWorldNodeModel.doc.md Write ← help page │ └── test/kotlin/…/HelloWorldNodeModelTest.kt Write ← unit test │ -├── features/continuum-feature-hello-java/ Delete if you only write Kotlin (same layout) +├── features/continuum-feature-hello-java/ Rename once same layout in Java; delete whichever example you don't need │ ├── worker/ │ ├── build.gradle.kts Keep in sync which modules the worker loads, image name @@ -66,14 +66,15 @@ continuum-feature-template/ │ ├── charts/continuum-feature-template/ Keep in sync Helm chart for Kubernetes ├── docker/ Leave alone local Continuum stack -└── .github/workflows/ Keep in sync CI and release (lists your modules) +├── .github/workflows/ Keep in sync CI and release (lists your modules) +└── README.md, CONTRIBUTING.md, AGENTS.md Rename once still describe the template ``` ## The files that matter ### Files you write -These three live side by side in each feature module and share a name: +These three live side by side in each feature module and share a name. The Java module has the same layout, with `HelloJavaNodeModel` and `.java` files: | File | What it is | |------|------------| @@ -90,7 +91,7 @@ If you get one of the first three wrong, the build still passes but **the worker | `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. If `basePackages` doesn't cover your node's package, the node isn't found. | | `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. If the file is missing or names the wrong class, Spring doesn't load your module. | | `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | -| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | +| `node/` package name | Node classes belong in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. (Other package names still load; the feature ID is then the whole package.) | If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). @@ -112,7 +113,7 @@ If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [c ## What the Gradle plugins do for you -You don't declare Spring, Temporal, Jackson or test dependencies. The two Continuum plugins add them: +You don't declare Spring, Temporal, Jackson or test dependencies. The three Continuum plugins add them: | Plugin | Used in | Gives you | |--------|---------|-----------| @@ -120,10 +121,6 @@ You don't declare Spring, Temporal, Jackson or test dependencies. The two Contin | `org.projectcontinuum.feature-java` | Java feature modules | The same, for Java. | | `org.projectcontinuum.worker` | `worker/` | Spring Boot, the worker starter (Temporal polling and node registration), `bootRun`, and Jib for the container image. | -Add a `dependencies { }` block to a feature module only when your node needs an extra library. - -:::info[Versions] -The template builds against Continuum platform `0.0.20` (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Everything comes from Maven Central, so you don't need a GitHub token. -::: +Add a `dependencies { }` block to a feature module only when your node needs an extra library; see [Add a library](./recipes.md#add-a-library). The plugin versions are the `continuumPlatformVersion` in `gradle.properties` (see the [version note in the overview](./overview.md#what-you-need)). Next: [rename the template](./step-3-make-it-yours.md). diff --git a/docs/contributing/create-new-nodes/step-3-make-it-yours.md b/docs/contributing/create-new-nodes/step-3-make-it-yours.md index eb241d7..0125ac5 100644 --- a/docs/contributing/create-new-nodes/step-3-make-it-yours.md +++ b/docs/contributing/create-new-nodes/step-3-make-it-yours.md @@ -8,60 +8,177 @@ title: "Step 3: Make it yours" Step 3 of 6 - About 20 minutes + About 5 minutes with the script, 20 by hand -The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. +The template carries its own name in many files. This step replaces it with yours and removes the example module in the language you don't use. It's mechanical, and you only do it once. -Pick your values first, and check the other Continuum repositories to make sure the names aren't already in use: +You have two ways to do it: run a [script](#option-a-run-the-rename-script) that does the whole job, or work through the [manual checklist](#option-b-the-manual-checklist). Both end at the same [leftover check](#check-for-leftovers). + +## Pick your values + +Pick these first, and check the other Continuum repositories to make sure the names aren't already in use: | Placeholder | Example | Used for | Changing it later | |-------------|---------|----------|-------------------| -| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Possible, but you repeat this whole step. | -| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | +| `` | `acme` | Your GitHub organisation or user, and your Docker Hub organisation | Easy. | +| `` | `continuum-feature-demo` | Repository, Gradle root project, feature module, Helm chart, worker and Docker image name | Possible, but you repeat this whole step. | +| `` | `com.acme.demo` | Package for your nodes (the node classes go in `.node`) | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | | `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique across all workers in your Continuum instance.** | Change it in `application.yaml` and the chart together. | +| `` | `featureDemo` | The key under `continuum:` in the Helm chart's values | Easy, but change it in every chart file. | + +:::warning[Pick a package you own] +Use a package that starts with a domain you control (`com.acme.demo`) or `io.github.`. Don't use `org.projectcontinuum.*`: that namespace belongs to the platform. The feature module's Maven `group` is set to your package, and **Maven Central only accepts a group whose namespace you've verified**. If you don't plan to publish your feature modules as libraries, you can ignore this and [switch publishing off in Step 6](./step-6-ship-it.md#3-add-repository-secrets). +::: + +:::danger[Pick a unique task queue now] +Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. +::: + +## Which example do you keep? + +The template ships the same Hello World node twice: `features/continuum-feature-hello` (Kotlin) and `features/continuum-feature-hello-java` (Java). Keep the one that matches the language you write and delete the other. Mixing languages in one module isn't supported by the template; if you want both, keep both modules and run through the checklist for each. + +## Option A: Run the rename script + +The script below does everything in [Option B](#option-b-the-manual-checklist) except editing the descriptions and the README. It's been tested on a fresh clone of the template for both the Kotlin and the Java variants, followed by `./gradlew build`. + +1. Commit or stash anything you changed so you can review the result with `git diff`. +2. Save the script as `rename.sh` **outside** the repository (for example in your home folder). +3. Edit the six values at the top, including `LANGUAGE`. +4. Run it from anywhere inside your clone: `bash ~/rename.sh`. + +It needs `bash` and `perl`, which macOS and Linux have. On Windows, use WSL or Git Bash. + +
+rename.sh + +```bash +#!/usr/bin/env bash +set -euo pipefail + +# ---- Edit these six values --------------------------------------------- +export ORG=acme # your GitHub organisation or user +export REPO=continuum-feature-demo # repository, module, chart and worker name +export PKG=com.acme.demo # package for your nodes (without .node) +export TASK_QUEUE=CONTINUUM_FEATURE_DEMO_TASK_QUEUE +export VALUES_KEY=featureDemo # key under `continuum:` in the Helm values +export IMAGE=acme/continuum-feature-demo # Docker image, without a tag +LANGUAGE=kotlin # kotlin or java: which example module to keep +# ------------------------------------------------------------------------- + +cd "$(git rev-parse --show-toplevel)" + +if [ "$LANGUAGE" = kotlin ]; then + KEEP=continuum-feature-hello + export OLD_PKG=org.projectcontinuum.feature.example + export DROP_RE='continuum-feature-hello-java' + export DROP_PLUGIN='id\("org\.projectcontinuum\.feature-java"\)' + DROP=continuum-feature-hello-java +else + KEEP=continuum-feature-hello-java + export OLD_PKG=org.projectcontinuum.feature.example.java + export DROP_RE='continuum-feature-hello(?!-java)' + export DROP_PLUGIN='id\("org\.projectcontinuum\.feature"\)' + DROP=continuum-feature-hello +fi +export SHORT="${REPO#continuum-}" +OLD_PATH="${OLD_PKG//.//}" +NEW_PATH="${PKG//.//}" + +# 1. Remove the example module you don't need +rm -rf "features/$DROP" +perl -ni -e 'print unless /$ENV{DROP_RE}/' \ + settings.gradle.kts worker/build.gradle.kts .github/workflows/build-module.yml +perl -ni -e 'print unless /$ENV{DROP_PLUGIN}/' settings.gradle.kts +perl -0pi -e 's/^ *- module: features:$ENV{DROP_RE}\n(?: +publish_\w+: \w+\n)+//m' \ + .github/workflows/on-release.yml + +# 2. Rename the module, package folders and chart folder +mv "features/$KEEP" "features/$REPO" +for d in src/main/kotlin src/main/java src/main/resources src/test/kotlin src/test/java; do + src="features/$REPO/$d/$OLD_PATH" + if [ -d "$src" ]; then + mkdir -p "features/$REPO/$d/$(dirname "$NEW_PATH")" + mv "$src" "features/$REPO/$d/$NEW_PATH" + fi +done +find "features/$REPO" -type d -empty -delete +mv charts/continuum-feature-template "charts/$REPO" + +# 3. Replace the template's names inside files +find . \( -name .git -o -name .gradle -o -name .kotlin -o -name build -o -name .idea \ + -o -path ./docker -o -path ./gradle \) -prune -o -type f ! -name 'gradlew*' -print0 | + xargs -0 perl -pi -e ' + s{org\.projectcontinuum\.feature\.example(\.java)?}{$ENV{PKG}}g; + s{projectcontinuum/continuum-feature-template}{$ENV{IMAGE}}g; + s{projectcontinuum-org/continuum-feature-template}{$ENV{ORG}/$ENV{REPO}}g; + s{continuum-feature-hello(-java)?}{$ENV{REPO}}g; + s{continuum-feature-template}{$ENV{REPO}}g; + s{CONTINUUM_FEATURE_TEMPLATE_TASK_QUEUE}{$ENV{TASK_QUEUE}}g; + s{featureTemplate}{$ENV{VALUES_KEY}}g; + s{feature-template}{$ENV{SHORT}}g; + ' +perl -pi -e 's{org\.projectcontinuum\.app\.worker\.example}{$ENV{PKG}.app.worker}g' worker/build.gradle.kts + +echo "Done. Still to do by hand: the description lines in build.gradle.kts and Chart.yaml, and README.md." +echo "Leftovers (expect none):" +grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ + --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . || true +``` + +
+ +When it finishes, the "Leftovers" list at the end of its output should be empty. Then finish by hand: + +- [ ] The `description` lines in `features//build.gradle.kts`, `worker/build.gradle.kts` and `charts//Chart.yaml`. The script renames words but can't rewrite a sentence. +- [ ] `README.md`, `CONTRIBUTING.md` and `AGENTS.md`: the script fixes names and links, but the text still describes the template (badges, the "Ownership" list in `AGENTS.md`, and so on). Rewrite what no longer applies. -## Checklist +Skip ahead to [Check for leftovers](#check-for-leftovers). + +## Option B: The manual checklist + +Work through this in order and commit when the build is green. `` below means the module you keep: `continuum-feature-hello` (Kotlin) or `continuum-feature-hello-java` (Java). ### 1. Project identity - [ ] `settings.gradle.kts`: set `rootProject.name = ""`. -- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. +- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. + +### 2. Remove the example you don't need + +- [ ] Delete the other module's folder under `features/`. +- [ ] Remove its `include(...)` line from `settings.gradle.kts`. +- [ ] Remove its `implementation(project(...))` line from `worker/build.gradle.kts`. +- [ ] `settings.gradle.kts` also declares the Gradle plugins in `pluginManagement { plugins { … } }`. Remove the `id("org.projectcontinuum.feature-java")` line if you keep Kotlin, or the `id("org.projectcontinuum.feature")` line if you keep Java. +- [ ] `.github/workflows/on-release.yml`: delete its `- module:` entry in the matrix, including the `publish_*` lines under it. +- [ ] `.github/workflows/build-module.yml`: delete its line in the `options:` list. -### 2. The feature module +### 3. The feature module -Rename the folder `features/continuum-feature-hello/` to `features//` and then: +Rename the folder `features//` to `features//` and then: -- [ ] `settings.gradle.kts`: change `include(":features:continuum-feature-hello")` to `include(":features:")`. -- [ ] `features//build.gradle.kts`: change `group` and `description`. -- [ ] Rename the package folders under `src/main/kotlin`, `src/test/kotlin` and `src/main/resources`, from `org/projectcontinuum/feature/example` to your `` path. Update the `package` line in every file you moved. -- [ ] `AutoConfigure.kt`: update the `basePackages` value in `@ComponentScan` to ``. +- [ ] `settings.gradle.kts`: change `include(":features:")` to `include(":features:")`. +- [ ] `features//build.gradle.kts`: change `group` to `` and rewrite `description`. +- [ ] Rename the package folders under `src/main/kotlin` (or `src/main/java`), `src/test/…` and `src/main/resources`. The old path is `org/projectcontinuum/feature/example` for Kotlin and `org/projectcontinuum/feature/example/java` for Java. Replace it with your `` path. Update the `package` line in every file you moved. +- [ ] `AutoConfigure.kt` (or `AutoConfigure.java`): update the `basePackages` value in `@ComponentScan` to ``. - [ ] `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`: change the line to `.AutoConfigure`. :::tip[Use your IDE's rename] -In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit the three text files above by hand: `AutoConfigure.kt`'s `basePackages`, the `.imports` file and the Gradle files. +In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit `basePackages`, the `.imports` file and the Gradle files by hand. ::: -### 3. Java example (optional) - -- [ ] If you only write Kotlin, delete `features/continuum-feature-hello-java/` and remove its `include(...)` from `settings.gradle.kts`, its `implementation(project(...))` from `worker/build.gradle.kts`, and its `id("org.projectcontinuum.feature-java")` line from `settings.gradle.kts`. -- [ ] If you keep it, repeat step 2 for it. - ### 4. The worker - [ ] `worker/build.gradle.kts`: - `implementation(project(":features:"))` must point at your renamed module. - - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. + - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. - Change `group` and `description`. - [ ] `worker/src/main/resources/application.yaml`: - `spring.application.name` → `-worker` - the default of `node-task-queue` → `` - the `org.projectcontinuum.feature.example` log level → `` -:::danger[Pick a unique task queue now] -Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. -::: - ### 5. The Helm chart The chart folder, its helper templates and its values keys all carry the template's name. Replace them together or Helm will fail with "template not found". @@ -69,31 +186,31 @@ The chart folder, its helper templates and its values keys all carry the templat - [ ] Rename `charts/continuum-feature-template/` to `charts//`. - [ ] `Chart.yaml`: change `name`, `description` and `home`. - [ ] `values.yaml` and `values-dev.yaml`: - - the `featureTemplate:` key → a name for your worker (for example `featureDemo:`) + - the `featureTemplate:` key → `` - `image.repository` → your image from `jibToImage` - `taskQueue` → `` (**the same value as in `application.yaml`**) -- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with your new values key, and the `feature-template` component label with your own. +- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with `..`, and the `feature-template` component label with your own. - [ ] `Chart.yaml` `appVersion` must equal `featureVersion` in `gradle.properties` (both `0.0.1` as shipped). ### 6. CI and release workflows -- [ ] `.github/workflows/on-release.yml`: update the `module:` entries in the matrix to your module names. -- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module names. +- [ ] `.github/workflows/on-release.yml`: update the `module:` entry for your module in the matrix. +- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module name. ### 7. Text files -- [ ] `README.md` and `CONTRIBUTING.md`: replace the template's name, badges and links. +- [ ] `README.md`, `CONTRIBUTING.md` and `AGENTS.md`: replace the template's name, badges, links and descriptions. ## Check for leftovers -Run this from the repository root. It should print nothing when you're done: +Run this from the repository root. It prints nothing when every rename is done: ```bash grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . ``` -If you kept the Java example or its folder name, `feature-hello` will still match; that's fine. Anything else is a missed rename. +Any line it prints is a missed rename. (`AGENTS.md` and `README.md` are the files most often missed.) Then confirm nothing broke: @@ -103,18 +220,19 @@ Then confirm nothing broke: If you changed the chart, also run `helm lint charts/`. +At this point the build contains the template's **Hello World** node under your name. That's expected: you replace it in the next step. + ### Before you move on - [ ] The module folder, the `include(...)` line in `settings.gradle.kts` and the `implementation(project(...))` line in `worker/build.gradle.kts` all use the same module name. - [ ] The `.imports` file names your real `AutoConfigure` class. -- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml` (if you updated the chart). -- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml` (if you updated the chart). +- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml`. +- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml`. - [ ] The leftover grep above prints nothing. -- [ ] `./gradlew build` passes, and `helm lint charts/` passes if you changed the chart. +- [ ] `./gradlew build` passes, and `helm lint charts/` passes. :::info[What you can skip for now] -You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. +You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need the project, module and worker sections. If you postpone them, the leftover grep will still report the chart and workflows. ::: Next: [write your node](./step-4-write-your-node.md). - diff --git a/docs/contributing/create-new-nodes/step-4-write-your-node.md b/docs/contributing/create-new-nodes/step-4-write-your-node.md index 7e001cb..8c2a345 100644 --- a/docs/contributing/create-new-nodes/step-4-write-your-node.md +++ b/docs/contributing/create-new-nodes/step-4-write-your-node.md @@ -4,6 +4,9 @@ sidebar_label: "4. Write your node" title: "Step 4: Write your node" --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # Step 4: Write your node @@ -11,7 +14,9 @@ title: "Step 4: Write your node" About 30 minutes -You don't start from a blank file. Rename the template's **Hello World** node and change what it does. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. +You don't start from a blank file. Take the template's **Hello World** node (or **Hello Java**) and **rewrite it** into your own: rename the files and the class, then replace the ports, settings and logic. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. + +Every code sample on this page was compiled and its tests were run against platform `0.0.20`. Pick your language in the tabs; the choice sticks across the page. A node is three files that share a name. Do them in this order: @@ -19,13 +24,15 @@ A node is three files that share a name. Do them in this order: 2. [The help page](#2-the-help-page) 3. [The unit test](#3-the-unit-test) +Once those work, [More node recipes](./recipes.md) shows how to add a second node, write a source node, use credentials and more. + ## 1. The node class -Rename `HelloWorldNodeModel.kt` to `WordCounterNodeModel.kt` (and the class inside it). The file has six parts. Only the numbered ones need your changes: +Rename `HelloWorldNodeModel.kt` (Java: `HelloJavaNodeModel.java`) to `WordCounterNodeModel.kt` (or `.java`) and the class inside it, then replace the contents. The class has six parts: ```text @ContinuumNode ← required, never remove -class WordCounterNodeModel(...) : ProcessNodeModel() { +class WordCounterNodeModel : ProcessNodeModel() { 1. ports what goes in and out 2. categories where it appears in the palette 3. propertiesSchema what settings exist, and what is valid @@ -35,10 +42,13 @@ class WordCounterNodeModel(...) : ProcessNodeModel() { } ``` -Here is the finished Word Counter, with the six parts marked: +Here is the finished Word Counter, with the six parts marked. It lives in the package `.node`, which is `com.acme.demo.node` in this example: + + + ```kotlin -package org.projectcontinuum.feature.demo.node +package com.acme.demo.node import org.projectcontinuum.core.commons.annotation.ContinuumNode import org.projectcontinuum.core.commons.exception.NodeRuntimeException @@ -58,12 +68,12 @@ class WordCounterNodeModel( private val whitespace = Regex("\\s+") - // 1. Ports. The map keys ("data") are the port IDs you use in execute(). + // 1. Ports. The map keys ("input", "output") are the port IDs you use in execute(). final override val inputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + "input" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) ) final override val outputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) + "output" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) ) // 2. Palette category @@ -128,12 +138,12 @@ class WordCounterNodeModel( ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "outputCol is not provided") val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 - val reader = inputs["data"] ?: throw NodeRuntimeException( - isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" + val reader = inputs["input"] ?: throw NodeRuntimeException( + isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'input' is not connected" ) val totalRows = reader.getRowCount() - nodeOutputWriter.createOutputPortWriter("data").use { writer -> + nodeOutputWriter.createOutputPortWriter("output").use { writer -> reader.use { var rowNumber = 0L while (true) { @@ -151,6 +161,152 @@ class WordCounterNodeModel( } ``` + + + +```java +package com.acme.demo.node; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.projectcontinuum.core.commons.annotation.ContinuumNode; +import org.projectcontinuum.core.commons.exception.NodeRuntimeException; +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel; +import org.projectcontinuum.core.commons.node.ProcessNodeModel; +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback; +import org.projectcontinuum.core.commons.utils.NodeInputReader; +import org.projectcontinuum.core.commons.utils.NodeOutputWriter; +import org.springframework.http.MediaType; +import tools.jackson.core.type.TypeReference; +import tools.jackson.databind.ObjectMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@ContinuumNode +public class WordCounterNodeModel extends ProcessNodeModel { + + private static final ObjectMapper MAPPER = new ObjectMapper(); + private static final TypeReference> MAP_TYPE = new TypeReference<>() {}; + + // 1. Ports. The map keys ("input", "output") are the port IDs you use in execute(). + private final Map inputPorts = Map.of( + "input", new ContinuumWorkflowModel.NodePort("Input Table", MediaType.APPLICATION_OCTET_STREAM_VALUE)); + private final Map outputPorts = Map.of( + "output", new ContinuumWorkflowModel.NodePort("Table with word counts", MediaType.APPLICATION_OCTET_STREAM_VALUE)); + + @NotNull @Override public Map getInputPorts() { return inputPorts; } + @NotNull @Override public Map getOutputPorts() { return outputPorts; } + + // 2. Palette category + @NotNull @Override public List getCategories() { return List.of("Demo"); } + + // 3. JSON Schema: the settings and their rules + private static final Map PROPERTIES_SCHEMA = MAPPER.readValue(""" + { + "type": "object", + "properties": { + "inputCol": { "type": "string", "title": "Input Column" }, + "outputCol": { "type": "string", "title": "Output Column" }, + "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } + }, + "required": ["inputCol", "outputCol"] + } + """, MAP_TYPE); + + // 4. JSON Forms UI schema: the layout of the settings form + private static final Map PROPERTIES_UI_SCHEMA = MAPPER.readValue(""" + { + "type": "VerticalLayout", + "elements": [ + { "type": "Control", "scope": "#/properties/inputCol" }, + { "type": "Control", "scope": "#/properties/outputCol" }, + { "type": "Control", "scope": "#/properties/minWordLength" } + ] + } + """, MAP_TYPE); + + // 5. Metadata. Java has no default arguments, so pass all 15 parameters in order. + private final ContinuumWorkflowModel.NodeData metadata = new ContinuumWorkflowModel.NodeData( + getClass().getName(), // id + "Counts the words in a text column and appends the count as a new column", // description + "Word Counter", // title + "Count words per row", // subTitle + null, // icon (SVG string, or null) + getClass().getName(), // nodeModel + null, // busy + inputPorts, // inputs + outputPorts, // outputs + Map.of("inputCol", "text", "outputCol", "word_count", "minWordLength", 1), // default settings + PROPERTIES_SCHEMA, // propertiesSchema + PROPERTIES_UI_SCHEMA, // propertiesUISchema + null, // status + null, // nodeProgress + null // retryOptions (null = workflow default) + ); + + @NotNull @Override public ContinuumWorkflowModel.NodeData getMetadata() { return metadata; } + + // 6. The logic + @Override + public void execute( + @Nullable Map properties, + @NotNull Map inputs, + @NotNull NodeOutputWriter nodeOutputWriter, + @NotNull NodeProgressCallback nodeProgressCallback + ) { + String inputCol = requireString(properties, "inputCol"); + String outputCol = requireString(properties, "outputCol"); + Object min = properties.get("minWordLength"); + int minWordLength = (min instanceof Number n) ? n.intValue() : 1; + + NodeInputReader reader = inputs.get("input"); + if (reader == null) { + throw new NodeRuntimeException(false, "", "", "Input port 'input' is not connected"); + } + long totalRows = reader.getRowCount(); + long rowNumber = 0; + + NodeOutputWriter.OutputPortWriter writer = nodeOutputWriter.createOutputPortWriter("output"); + try { + Map row; + while ((row = reader.read()) != null) { + Object cell = row.get(inputCol); + String text = cell == null ? "" : cell.toString().trim(); + int count = 0; + if (!text.isEmpty()) { + for (String word : text.split("\\s+")) { + if (word.length() >= minWordLength) count++; + } + } + Map out = new HashMap<>(row); + out.put(outputCol, count); + writer.write(rowNumber, out); + rowNumber++; + if (totalRows > 0) nodeProgressCallback.report((int) (rowNumber * 100 / totalRows)); + } + } finally { + writer.close(); + reader.close(); + } + } + + private static String requireString(Map properties, String key) { + Object value = properties == null ? null : properties.get(key); + if (!(value instanceof String s)) { + throw new NodeRuntimeException(false, "", "", key + " is not provided"); + } + return s; + } +} +``` + +In Java the three overrides `getInputPorts()`, `getOutputPorts()` and `getCategories()` replace Kotlin's `override val` properties, and the `@NotNull` / `@Nullable` annotations match the Kotlin signatures. The 15 arguments to `NodeData` are in the order shown by the comments. + + + + ### Rules the platform enforces Break one of these and the build fails, the node doesn't load, or workflows break later. @@ -158,37 +314,45 @@ Break one of these and the build fails, the node doesn't load, or workflows brea | Rule | Why | |------|-----| | Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it (`validateContinuumNodeAnnotations`). | -| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | -| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | -| Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | +| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. See [a source node](./recipes.md#a-source-node-with-no-inputs). | +| Set `metadata.id` and `metadata.nodeModel` to the class's full name (`this.javaClass.name` / `getClass().getName()`). | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | +| Put the class in a package that ends in `.node`. | By convention. The platform removes that last segment to get the feature ID (`com.acme.demo.node` → `com.acme.demo`). Without it, the whole package name becomes the feature ID, and the node still loads. | | Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.*` (Jackson 2) won't compile. | -| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | + +Two notes on `ObjectMapper`: + +- In Kotlin you can take it as a constructor parameter and Spring injects it. In unit tests, pass `jacksonObjectMapper()`. +- In Java, the example creates a `static` mapper, which works because the schemas are built once when the class loads. You can also take an `ObjectMapper` in a constructor, as in Kotlin. + +If you'd rather not parse JSON strings at all, you can write the schemas as nested `mapOf(...)` / `Map.of(...)` values. The [source node](./recipes.md#a-source-node-with-no-inputs) recipe does that. ### Ports `inputPorts` and `outputPorts` are maps: -- The **key** (for example `"data"`) is the port ID you use in `execute()` to read or write data. +- The **key** (here `"input"` and `"output"`) is the port ID you use in `execute()` to read or write data. The template's Hello World node uses the same two IDs, so the rest of the platform's examples look familiar. - The **value** is a `ContinuumWorkflowModel.NodePort` with a `name` (shown in the Workbench) and a `contentType`. Table ports use `APPLICATION_OCTET_STREAM_VALUE`, as in the running example. The template's example nodes do the same. +A node can have **several ports**. Add more entries to the map, give each a different key, and use those keys in `inputs["…"]` and `createOutputPortWriter("…")`. A node with two inputs (for example `"left"` and `"right"`) gets both readers in the `inputs` map; check each key you need, because a port that isn't connected is missing from the map. + ### Settings and validation - `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. - Before `execute()` runs, the platform checks the user's settings against `propertiesSchema`. Values that break `required`, `type` or `minimum` fail the node before your code starts. Checking again in `execute()` is still worthwhile because it lets you give a clearer error message. -- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. +- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](./recipes.md#use-a-credential). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. ### Reading and writing rows -- `inputs["data"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. -- `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. -- Wrap both in `.use { }`. The output file is only complete once the writer is closed. +- `inputs["input"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. +- `createOutputPortWriter("output")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. +- Close both when you are done: Kotlin's `.use { }` or Java's `try { … } finally { … }`. The output file is only complete once the writer is closed. Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Leave a key out instead of storing `null`. -| Kotlin type | Stored as | -|-------------|-----------| +| Kotlin / Java type | Stored as | +|--------------------|-----------| | `String` | `application/vnd.continuum.x-string` | | `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | | `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | @@ -200,23 +364,25 @@ Convert anything else first. For example, call `toString()` on a `LocalDate`, an ### Errors, retries and progress -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as: +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` (Java: `new NodeRuntimeException(false, "", "", message)`) for errors a retry can't fix, such as: - Missing or invalid settings (user error) - An unconnected input port - Invalid input data that can't be recovered from Empty strings are fine for `workflowId` and `nodeId` in the exception. +To change the retry behaviour of one node, see [per-node retry options](./recipes.md#change-a-nodes-retry-behaviour). + Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. ## 2. The help page -Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. +Rename `HelloWorldNodeModel.doc.md` (Java: `HelloJavaNodeModel.doc.md`) to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. -The path must match the node's package and class name exactly. For the class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`, the file is: +The path must match the node's package and class name exactly. For the class `com.acme.demo.node.WordCounterNodeModel`, the file is: ```text -src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md +src/main/resources/com/acme/demo/node/WordCounterNodeModel.doc.md ``` To build the path, take the class's full name, replace each `.` with `/` and add `.doc.md`. The `node` folder is part of the package, not an extra segment. @@ -227,9 +393,28 @@ A good help page has four parts, as in the template's Hello World page: what the ## 3. The unit test -Rename `HelloWorldNodeModelTest.kt` to `WordCounterNodeModelTest.kt`. Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. +Rename `HelloWorldNodeModelTest.kt` (Java: `HelloJavaNodeModelTest.java`) to `WordCounterNodeModelTest.kt` (or `.java`). Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. + + + ```kotlin +package com.acme.demo.node + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.argumentCaptor +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import tools.jackson.module.kotlin.jacksonObjectMapper + class WordCounterNodeModelTest { private val outputWriter = mock() private val portWriter = mock() @@ -237,14 +422,14 @@ class WordCounterNodeModelTest { @BeforeEach fun setUp() { - whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) + whenever(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter) } @Test fun `counts words and keeps original columns`() { val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) - node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("input" to reader), outputWriter, mock()) val rows = argumentCaptor>() verify(portWriter).write(any(), rows.capture()) @@ -252,6 +437,28 @@ class WordCounterNodeModelTest { assertEquals(1, rows.firstValue["id"]) } + @Test + fun `ignores words shorter than the minimum length`() { + val reader = mockReader(listOf(mapOf("text" to "a quick brown fox"))) + + node.execute( + mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 4), + mapOf("input" to reader), outputWriter, mock() + ) + + val rows = argumentCaptor>() + verify(portWriter).write(any(), rows.capture()) + assertEquals(2, rows.firstValue["word_count"]) + } + + @Test + fun `fails without retry when the input port is not connected`() { + val error = assertThrows(NodeRuntimeException::class.java) { + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), emptyMap(), outputWriter, mock()) + } + assertEquals(false, error.isRetriable) + } + private fun mockReader(rows: List>): NodeInputReader { val iterator = rows.iterator() return mock().also { r -> @@ -262,7 +469,66 @@ class WordCounterNodeModelTest { } ``` -The template's `HelloWorldNodeModelTest` has more cases to copy, including metadata checks and progress reporting. + + + +```java +package com.acme.demo.node; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback; +import org.projectcontinuum.core.commons.utils.NodeInputReader; +import org.projectcontinuum.core.commons.utils.NodeOutputWriter; + +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.*; + +class WordCounterNodeModelTest { + + private final NodeOutputWriter outputWriter = mock(NodeOutputWriter.class); + private final NodeOutputWriter.OutputPortWriter portWriter = mock(NodeOutputWriter.OutputPortWriter.class); + private final WordCounterNodeModel node = new WordCounterNodeModel(); + + @BeforeEach + void setUp() { + when(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter); + } + + @Test + @SuppressWarnings("unchecked") + void countsWordsAndKeepsOriginalColumns() { + NodeInputReader reader = mockReader(List.of(Map.of("id", 1, "text", "the quick brown fox"))); + + node.execute( + Map.of("inputCol", "text", "outputCol", "word_count"), + Map.of("input", reader), outputWriter, mock(NodeProgressCallback.class)); + + ArgumentCaptor> row = ArgumentCaptor.forClass(Map.class); + verify(portWriter).write(anyLong(), row.capture()); + assertEquals(4, row.getValue().get("word_count")); + assertEquals(1, row.getValue().get("id")); + } + + private NodeInputReader mockReader(List> rows) { + var iterator = rows.iterator(); + NodeInputReader reader = mock(NodeInputReader.class); + when(reader.read()).thenAnswer(i -> iterator.hasNext() ? iterator.next() : null); + when(reader.getRowCount()).thenReturn((long) rows.size()); + return reader; + } +} +``` + + + + +The template's Hello World test has more cases to copy, including metadata checks and progress reporting. :::note These tests call `execute()` directly, so they skip the schema validation. To test validation as well, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. diff --git a/docs/contributing/create-new-nodes/step-5-test-and-run.md b/docs/contributing/create-new-nodes/step-5-test-and-run.md index 25961da..7d87478 100644 --- a/docs/contributing/create-new-nodes/step-5-test-and-run.md +++ b/docs/contributing/create-new-nodes/step-5-test-and-run.md @@ -39,13 +39,22 @@ Make sure the local stack from Step 1 is still up (`docker compose ps` in `docke ## 3. Check the node was loaded -Ask the worker which nodes it serves: +The worker logs every node it found when it starts. Look for these two lines in the `bootRun` output: + +```text +Registered process nodes: [com.acme.demo.node.WordCounterNodeModel] +Registered trigger nodes: [] +``` + +Your node's full class name should be in the list. You can also ask the worker over HTTP: ```bash curl http://localhost:8090/api/v1/node-repo ``` -Your **Word Counter** should be in the response. If it isn't, the build passed but the worker didn't find your node. Follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). It covers the four usual causes: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class, `@ComponentScan` doesn't cover your package, or the class is missing `@ContinuumNode`. +Your **Word Counter** should be in the response. + +If it isn't, the build passed but the worker didn't find your node. Work through the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). Most often, one of these is wrong: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class or `@ComponentScan` doesn't cover your package. (A missing `@ContinuumNode` is rarely the cause, because the build catches it.) ## 4. Run it in the Workbench diff --git a/docs/contributing/create-new-nodes/step-6-ship-it.md b/docs/contributing/create-new-nodes/step-6-ship-it.md index 096ea14..7b8bdbc 100644 --- a/docs/contributing/create-new-nodes/step-6-ship-it.md +++ b/docs/contributing/create-new-nodes/step-6-ship-it.md @@ -11,7 +11,7 @@ title: "Step 6: Ship it" Needs repository secrets -Shipping is mostly already set up in the template. This page explains what each piece does and what you need to provide. +Shipping is mostly already set up in the template. This page explains what each piece does, what you need to provide and how to install the result. ## The release flow @@ -27,7 +27,7 @@ flowchart TB G --> H["GitHub release triggers workflows"] H --> I["Feature modules to Maven Central"] H --> J["Worker image to Docker Hub"] - H --> K["Helm chart to gh-pages"] + H --> K["Helm chart attached to the release
and added to the gh-pages index"] ``` :::warning[Publish a GitHub Release] @@ -53,6 +53,8 @@ featureVersion=0.0.2 appVersion: "0.0.2" # Must match gradle.properties ``` +The Docker image tag defaults to the chart's `appVersion`, so the chart installs exactly the image built from the same release. + ## 2. What CI runs | Workflow | When | What it does | @@ -62,7 +64,7 @@ appVersion: "0.0.2" # Must match gradle.properties | `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | | `build-module.yml` | Manual | Build one module, optionally publish it | | `on-release.yml` | GitHub release published | Libraries → Maven Central, worker → Docker Hub | -| `release.yml` | GitHub release published | Package the Helm chart and update the `gh-pages` index | +| `release.yml` | GitHub release published | Attach the packaged Helm chart to the release and update the `gh-pages` index | :::info[Workflows are triggered by a published release] `on-release.yml` and `release.yml` run when you **publish a GitHub Release** (Repository → Releases → Create a new release). Pushing a tag or merging to `main` doesn't trigger them. @@ -76,34 +78,106 @@ The release workflows read these from your repository's **Settings → Secrets a |--------|----------|-----------| | `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | If publishing to Maven Central | | `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | If publishing to Maven Central | -| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, always needed | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, unless you change the image registry (see [below](#4-where-the-image-goes)) | + +### Publishing libraries to Maven Central + +Maven Central only accepts artifacts whose `group` is a namespace you have **verified** in the Central Portal. Your feature module's `group` is your `` (for example `com.acme.demo`), so verify `com.acme.demo`'s parent domain (`com.acme`) or use `io.github.`. The Central Portal's namespace documentation explains the DNS or GitHub proof. :::tip[Not publishing libraries?] -If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. +If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets, and you don't need a verified namespace. Do both of these: -You still need Docker Hub secrets to publish the worker image. +1. In each feature module's `continuum { }` block, add `publishToMavenCentral.set(false)`. +2. In `.github/workflows/on-release.yml`, set `publish_to_maven: false` for those modules. + +Otherwise the release workflow tries to publish and fails on the missing secrets or namespace. ::: -## 4. Verify before deployment +## 4. Where the image goes + +The worker image is built with Jib, so you don't need a Dockerfile and the CI runner doesn't need Docker. The target is `jibToImage` in `worker/build.gradle.kts`: + +```kotlin +continuum { + continuumVersion.set(continuumPlatformVersion) + jibToImage.set("acme/continuum-feature-demo:${project.version}") +} +``` + +`on-release.yml` runs `./gradlew :worker:jib`, which pushes that image using the `DOCKER_REPO_USERNAME` and `DOCKER_REPO_PASSWORD` environment variables. The workflow fills them from `DOCKER_HUB_USERNAME` and `DOCKER_HUB_PASSWORD`. + +To use **another registry** (GitHub Container Registry, a private registry), put its full address in `jibToImage` (for example `ghcr.io/acme/continuum-feature-demo:${project.version}`), keep the same environment variable names, and change the `env:` lines of the "Push container image" step in `on-release.yml` to read your registry's credentials. Also change `image.repository` in the chart's `values.yaml` to match. + +If the registry is **private**, your cluster needs a pull secret. The template chart's `global.imagePullSecrets` value exists, but the Deployment template doesn't use it yet. Add this under `spec.template.spec` in `charts//templates/deployment.yaml`: + +```yaml + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} +``` + +Then create the secret in the namespace (`kubectl create secret docker-registry …`) and list it in `values.yaml`: + +```yaml +global: + imagePullSecrets: + - name: my-registry-secret +``` -Before installing the chart to Kubernetes, verify these critical synchronization points: +## 5. Configure the chart + +The chart wires your worker to the rest of the platform through the `continuum:` block in `values.yaml`. Three parts of it need your attention: + +| Values | What it is | When to change it | +|--------|-----------|-------------------| +| `continuum.infra.*` | Addresses of the shared services: Temporal (`host`, `port`, `namespace`), Kafka (`brokerList`), the schema registry (`url`) and MinIO (`endpoint`). | If you didn't install the `continuum-infra` chart under its default release name `continuum-infra`. Each address contains that release name. | +| `continuum.secrets.existingMinioSecret` | The name of the Kubernetes Secret that holds MinIO's `root-user` and `root-password`. Your chart doesn't create it; the `continuum-platform` chart does, named `-minio-secret`. | If you installed `continuum-platform` under a name other than `continuum-platform`. | +| `continuum.apiServer` | `host` and `port` of the platform's API server, where your worker registers its nodes. The default is the service `continuum-platform-api-server` on port 8080. | Same: if the release name differs. | + +Find the real service and secret names in your cluster with: + +```bash +kubectl get svc,secret -n continuum +``` + +Your worker's own settings are under `continuum.` (`image`, `replicas`, `taskQueue`, `resources`, `autoscaling`). + +## 6. Verify before deployment + +Before installing the chart, check the points that must agree: - [ ] `taskQueue` in `charts//values.yaml` matches `node-task-queue` in `application.yaml` - [ ] `taskQueue` is globally unique (search other workers) -- [ ] `image.repository` in values.yaml matches what your release pushes to Docker Hub -- [ ] The `continuum.infra.*` and `apiServer` hosts match the release names of other Continuum services +- [ ] `image.repository` in `values.yaml` matches what your release pushes +- [ ] The `continuum.infra.*`, `secrets.existingMinioSecret` and `apiServer` values match the release names in your cluster (see above) +- [ ] `helm lint charts/` passes + +## 7. Install -Then install: +You can install from your working copy, or from the chart your release published. + +**From the repository (good for a first test):** ```bash helm install ./charts/ -n continuum ``` -See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup. +**From your release:** the `release.yml` workflow attaches the packaged chart (`-.tgz`) to the GitHub release and adds it to the Helm index on your `gh-pages` branch. Enable GitHub Pages for the `gh-pages` branch in your repository settings (**Settings → Pages**), then: + +```bash +helm repo add https://.github.io/ +helm repo update +helm install / -n continuum +``` + +For a private repository the index isn't publicly readable. Download the `.tgz` from the release and run `helm install ./-0.0.2.tgz -n continuum` instead. + +To roll out a new version, publish a new release and run `helm upgrade`. See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup, and confirm the result by looking for your nodes in the Workbench, or check the worker's log for `Registered process nodes: [...]`. ## Worker configuration reference -You don't need to set Kafka, MinIO or the API server addresses; the worker starter ships defaults that match the local stack. Override them with environment variables when you deploy elsewhere: +You don't need to set Kafka, MinIO or the API server addresses locally; the worker starter ships defaults that match the local stack. In Kubernetes, the chart sets these for you from `values.yaml`. Override them with environment variables when you deploy some other way: | Variable | Default | Purpose | |----------|---------|---------| @@ -115,7 +189,7 @@ You don't need to set Kafka, MinIO or the API server addresses; the worker start | `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Schema registry | | `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage for node data | | `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` | MinIO credentials | -| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()` | +| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()`. The template chart doesn't set it; see [Use a credential](./recipes.md#use-a-credential). | | `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local scratch folder | | `SERVER_PORT` | `8090` | Worker HTTP port (8080 belongs to the API server) | diff --git a/docs/contributing/create-new-nodes/troubleshooting.md b/docs/contributing/create-new-nodes/troubleshooting.md index 22e6950..8f48af6 100644 --- a/docs/contributing/create-new-nodes/troubleshooting.md +++ b/docs/contributing/create-new-nodes/troubleshooting.md @@ -1,5 +1,5 @@ --- -sidebar_position: 8 +sidebar_position: 9 sidebar_label: Troubleshooting title: Troubleshooting --- @@ -10,35 +10,58 @@ title: Troubleshooting The build passes but your node isn't in the palette. Work down this list in order. -1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy. If it isn't in the response, continue with the checks below. -2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: +1. **Did the worker find the node?** Look at the `bootRun` output for the line `Registered process nodes: [...]` (or `Registered trigger nodes: [...]` for a source node). If your class is listed, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy (`docker compose ps` in `docker/`). If the list is empty or your class is missing, continue with the checks below. +2. **Is the worker registered with the API server?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. The worker must be able to reach the API server (`CONTINUUM_API_SERVER_BASE_URL`, default `http://localhost:8080`). +3. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: ```bash grep "implementation(project" worker/build.gradle.kts ``` -3. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: +4. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: ```bash cat features//src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports ``` It must contain exactly `.AutoConfigure`. -4. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt`, `basePackages` must include your node's package. The node class must be in that package or below. -5. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. The build fails without it, so if `./gradlew build` passed, this is rarely the cause. +5. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt` (or `src/main/java/…/AutoConfigure.java`), `basePackages` must include your node's package. The node class must be in that package or below. +6. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. `./gradlew build` fails without it (`validateContinuumNodeAnnotations`), so if the build passed, this is rarely the cause. After fixing any of these, rebuild and restart the worker. Reloading the browser isn't enough. -Still not appearing? Check that the node's package ends in `.node`, that the build output has no compilation errors, and that the local stack is healthy (`docker compose ps` in `docker/`). As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. +If it is still missing, check that the build output has no compilation errors and that the local stack is healthy. As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. -## Errors +## My node appears but fails when it runs + +- Look at the worker console (the `bootRun` output). Your `execute()` exception and stack trace are there. +- A node that fails and then runs again is being **retried**. If the cause can't change between attempts (bad settings, an unconnected port), throw `NodeRuntimeException(isRetriable = false, …)`; see [Errors, retries and progress](./step-4-write-your-node.md#errors-retries-and-progress). +- Reproduce it in a unit test with the same settings and input rows. This is faster than rerunning a workflow. + +## Build and start-up errors | Symptom | Cause and fix | |---------|---------------| | `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | | `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`, not `com.fasterxml.jackson.*`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | +| `Unsupported class file major version` or `invalid source release: 21` | The build runs on the wrong JDK. Run `java -version` and `./gradlew --version`; both must report 21. Set `JAVA_HOME` to a JDK 21 and stop old daemons with `./gradlew --stop`. | +| `Java heap space`, `GC overhead limit exceeded` or the Gradle daemon dies during compilation | Gradle needs more memory. The template sets `org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g` in `gradle.properties`. Keep that line; if you removed it, put it back, and make sure the machine has the memory to spare. | | `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | +| Worker starts but logs connection errors for Kafka, Temporal or MinIO | The local stack isn't running or isn't healthy. Run `docker compose ps` in `docker/` and wait until every container is healthy. The stack needs about 8 GB of RAM, so raise Docker Desktop's memory limit if containers keep restarting or get killed. | +| Worker starts but registers `[]` for both process and trigger nodes | The worker didn't load your module. See the [checklist above](#my-node-doesnt-show-up-in-the-workbench), steps 3 to 5. | +| `NoSuchBeanDefinitionException` or `UnsatisfiedDependencyException` for your node at start-up | The node's constructor asks for a bean Spring can't provide. Nodes can take `ObjectMapper`; anything else must be a bean from the worker. If in doubt, make the constructor empty. | | A node fails at random, or runs on the wrong worker | Several workers share a task queue. Temporal gives work to whichever worker polls first, including one that doesn't have the node, and nothing warns you. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | | `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (String, Int, Long, Float, Double, Boolean, List, Map or SVG). Convert it, or leave the key out instead of using `null`. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `org.example.node.MyNodeModel` it is `src/main/resources/org/example/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| `CredentialsNotFoundException` | The credential name in the node's settings doesn't exist on the credentials server. In the local stack there is no credentials server at all; see [Use a credential](./recipes.md#use-a-credential). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `com.acme.demo.node.MyNodeModel` it is `src/main/resources/com/acme/demo/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | + +## Release and deployment errors + +| Symptom | Cause and fix | +|---------|---------------| | Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | | PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| Release workflow doesn't start | `on-release.yml` and `release.yml` run on a **published GitHub Release**, not on a tag or a merge. See [Step 6](./step-6-ship-it.md#the-release-flow). | +| Maven Central deploy fails with a namespace or signing error | The `group` (your package) isn't a namespace you verified in the Central Portal, or the GPG secrets are missing. Verify the namespace, or switch publishing off; see [Step 6](./step-6-ship-it.md#3-add-repository-secrets). | +| Jib push fails with `401 Unauthorized` or `denied` | `DOCKER_HUB_USERNAME` / `DOCKER_HUB_PASSWORD` are missing or wrong, or the account can't push to the repository named in `jibToImage`. See [Step 6](./step-6-ship-it.md#4-where-the-image-goes). | +| Pod stuck in `ImagePullBackOff` | The image name or tag in the chart doesn't exist, or the registry is private and the pod has no pull secret. See [Step 6](./step-6-ship-it.md#4-where-the-image-goes). | +| Pod stuck in `Init` | An init container is waiting for Kafka, Temporal or the API server. Its address in `continuum.infra.*` or `continuum.apiServer` doesn't match a real service. Check with `kubectl get svc -n continuum` and see [Step 6](./step-6-ship-it.md#5-configure-the-chart). | +| Pod fails to start because a Secret is missing | `continuum.secrets.existingMinioSecret` names a Secret that doesn't exist in the namespace. See [Step 6](./step-6-ship-it.md#5-configure-the-chart). | | Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows, so don't rename classes after shipping. | - diff --git a/docs/contributing/feature-template.md b/docs/contributing/feature-template.md index 244b8db..a379f9f 100644 --- a/docs/contributing/feature-template.md +++ b/docs/contributing/feature-template.md @@ -11,7 +11,7 @@ Continuum is designed to be extended by **adding new workers**, not modifying ex To build your own set of nodes, start from [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) — a scaffold for a standalone Gradle project with the Spring Boot worker setup, Temporal registration, and `@ContinuumNode` conventions already wired up. :::tip -The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it and writing your first node, see [Create New Nodes](./create-new-nodes/overview.md). +The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it, writing your first node (in Kotlin or Java) and shipping it, see [Create New Nodes](./create-new-nodes/overview.md). ::: Once your worker is running and registering nodes, it can be deployed as an independent release into the same Kubernetes namespace as the core platform (see [Deployment](../deployment/helm-charts.md)) — no changes to `continuum-platform-core` or any other feature repo required. diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 9a245ea..801c439 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -159,7 +159,7 @@ const config: Config = { prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, - additionalLanguages: ['kotlin', 'bash', 'yaml', 'json'], + additionalLanguages: ['kotlin', 'java', 'bash', 'yaml', 'json', 'properties'], }, // Diagrams colour their nodes with translucent classDefs so they read in both modes. mermaid: { diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md index 00cfffd..f197fff 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md @@ -23,7 +23,7 @@ Start from the **`continuum-feature-template`** repository, rename it, replace i A **node** is a block on the Workbench canvas that reads tables, does something and writes tables. Nodes live in a **feature worker**, a small Spring Boot app that registers its nodes with the platform at startup. -You don't build a worker from scratch. The template is already a complete, working worker with two example nodes, a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. +You don't build a worker from scratch. The template is already a complete, working worker with two example nodes (one Kotlin, one Java), a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. ```mermaid flowchart LR @@ -34,11 +34,12 @@ flowchart LR | Requirement | Notes | |-------------|-------| -| JDK 21 | Eclipse Temurin recommended. | +| JDK 21 | Eclipse Temurin recommended. Check with `java -version`. | | Docker and Compose | Runs the local Continuum stack, about 8 GB of RAM. | | Some Kotlin or Java | You don't need to know Temporal, Kafka or Spring internals. | +| A GitHub account | The template is used from GitHub, and the release steps run on GitHub Actions. | -You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. +You don't need a GitHub token, and you don't need to install Gradle: the repository includes the wrapper. Everything comes from Maven Central. To publish your work you also need Docker Hub (or another registry) credentials, and optionally a Maven Central account; [Step 6](./step-6-ship-it.md) covers both. ## The steps @@ -47,16 +48,19 @@ You don't need a GitHub token, and you don't need to install Gradle: the reposit 1. [Clone the template and run it](./step-1-clone-and-run.md): see the example nodes working before you change anything. 2. [Tour the template](./step-2-tour-the-template.md): which files you write, which you rename and which you leave alone. 3. [Make it yours](./step-3-make-it-yours.md): a checklist for renaming the project, packages, worker and chart. -4. [Write your node](./step-4-write-your-node.md): the node class, its help page and its unit test. +4. [Write your node](./step-4-write-your-node.md): the node class (Kotlin and Java), its help page and its unit test. 5. [Test and run your node](./step-5-test-and-run.md): build, run the worker and use your node in the Workbench. 6. [Ship it](./step-6-ship-it.md): versions, CI, release and Kubernetes. +After the six steps, [More node recipes](./recipes.md) covers adding more nodes, source nodes, credentials, retries, extra libraries, logging and debugging. + ## Where to look when something breaks - Your node doesn't appear in the Workbench: [Troubleshooting](./troubleshooting.md). - The platform's side of registration: [Node Model & Feature Registration](../../architecture/node-model.md). +- A full list of errors and fixes, from the build to Kubernetes: [Troubleshooting](./troubleshooting.md). - The template's own README and `AGENTS.md` list its commands and rules. :::info[Versions] diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/recipes.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/recipes.md new file mode 100644 index 0000000..0f779a4 --- /dev/null +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/recipes.md @@ -0,0 +1,276 @@ +--- +sidebar_position: 8 +sidebar_label: "More node recipes" +title: "More node recipes" +--- + +# More node recipes + + + After Step 5 + Kotlin examples + + +[Step 4](./step-4-write-your-node.md) builds one process node. This page covers what you reach for next. The Kotlin code on this page was compiled and its tests were run against platform `0.0.20`. Java versions follow the same shape as the Java Word Counter in Step 4, and the notes below say where the API differs. + +## Add a second node + +You don't need a new module for every node. Add another class to the same package: + +1. Create `/node/MyOtherNodeModel.kt` next to your first node, annotated with `@ContinuumNode`. +2. Add `MyOtherNodeModel.doc.md` in the matching resources folder. +3. Add a test. +4. Bump `featureVersion` and the chart's `appVersion` before you ship ([Step 6](./step-6-ship-it.md#1-bump-the-version)). + +That's all. `AutoConfigure` already scans your whole package, so there is nothing to register. Rebuild and restart the worker; it logs every node it found: + +```text +Registered process nodes: [com.acme.demo.node.WordCounterNodeModel, com.acme.demo.node.MyOtherNodeModel] +Registered trigger nodes: [...] +``` + +Create a **second module** only when you want to publish some nodes as a separate library, or keep unrelated nodes apart. A new module needs a folder under `features/`, an `include(...)` in `settings.gradle.kts`, an `implementation(project(...))` in `worker/build.gradle.kts`, its own `AutoConfigure` and `.imports` file, and entries in the two workflow files. [Step 2](./step-2-tour-the-template.md#files-that-must-agree-with-each-other) lists everything that must agree. + +## A source node with no inputs + +A node that creates data from nothing (a generator, a file reader, an API poll) extends `TriggerNodeModel` instead of `ProcessNodeModel`. It has no `inputPorts`, and `execute()` has no `inputs` parameter: + +```kotlin +package com.acme.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.TriggerNodeModel +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE + +@ContinuumNode +class NumberGeneratorNodeModel : TriggerNodeModel() { + + final override val outputPorts = mapOf( + "output" to ContinuumWorkflowModel.NodePort(name = "Numbers", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + + override val categories = listOf("Demo") + + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "Number Generator", + subTitle = "Create a table of numbers", + description = "Creates a table with a number column and its square", + outputs = outputPorts, + properties = mapOf("count" to 10), + propertiesSchema = mapOf( + "type" to "object", + "properties" to mapOf("count" to mapOf("type" to "integer", "title" to "Row Count", "minimum" to 1)), + "required" to listOf("count") + ), + propertiesUISchema = mapOf( + "type" to "VerticalLayout", + "elements" to listOf(mapOf("type" to "Control", "scope" to "#/properties/count")) + ) + ) + + override fun execute(properties: Map?, nodeOutputWriter: NodeOutputWriter) { + val count = (properties?.get("count") as Number?)?.toInt() ?: 10 + + nodeOutputWriter.createOutputPortWriter("output").use { writer -> + for (n in 0 until count) { + writer.write(n.toLong(), mapOf("n" to n, "square" to n * n)) + } + } + } +} +``` + +Everything else from Step 4 applies: the `.doc.md` help page, the package rule, the row types and the test approach. In a test you call `execute(properties, outputWriter)` with just two arguments. + +This example builds its schemas with `mapOf(...)` instead of parsing JSON strings. Both styles work; `mapOf` needs no `ObjectMapper`. + +## Use a credential + +Nodes that call an API, a database or a cloud service shouldn't take secrets as plain settings. Store the secret as a **credential** in the platform, let the user pick it in the node's form, and read it in `execute()`. + +There are three pieces: + +1. The settings hold only the credential's **name**. +2. The UI schema marks that control with `options.format = "credential"`, so the Workbench shows a credential picker. +3. `execute()` takes an extra `ExecutionContext` parameter and calls `getCredential`. + +```kotlin +package com.acme.demo.node + +import org.projectcontinuum.core.commons.annotation.ContinuumNode +import org.projectcontinuum.core.commons.context.ExecutionContext +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel +import org.projectcontinuum.core.commons.node.ProcessNodeModel +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE + +@ContinuumNode +class ApiLookupNodeModel : ProcessNodeModel() { + + final override val inputPorts = mapOf( + "input" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + final override val outputPorts = mapOf( + "output" to ContinuumWorkflowModel.NodePort(name = "Output Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + ) + override val categories = listOf("Demo") + + override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "API Lookup", + description = "Calls an API with a stored credential", + inputs = inputPorts, + outputs = outputPorts, + properties = mapOf("credential" to ""), + propertiesSchema = mapOf( + "type" to "object", + "properties" to mapOf("credential" to mapOf("type" to "string", "title" to "Credential")), + "required" to listOf("credential") + ), + propertiesUISchema = mapOf( + "type" to "VerticalLayout", + "elements" to listOf( + mapOf( + "type" to "Control", + "scope" to "#/properties/credential", + "options" to mapOf("format" to "credential", "credentialType" to "GENERIC") + ) + ) + ) + ) + + // The shape of the credential's key-value data + data class ApiKey(val key: String) + + override fun execute( + properties: Map?, + inputs: Map, + nodeOutputWriter: NodeOutputWriter, + nodeProgressCallback: NodeProgressCallback, + executionContext: ExecutionContext + ) { + val name = properties?.get("credential") as String? + ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "No credential selected") + val apiKey = executionContext.getCredential(name) + + nodeOutputWriter.createOutputPortWriter("output").use { writer -> + writer.write(0L, mapOf("key_length" to apiKey.key.length)) + } + } +} +``` + +The example only writes the length of the key. **Never write secrets to an output port or a log.** In your own node, use the key to call the API and write the response. + +Things to know: + +- `getCredential` throws `CredentialsNotFoundException` if no credential has that name. Decide whether that should be retried; usually it is a user error and should become a non-retriable `NodeRuntimeException`. +- In Java, call `executionContext.getCredential(name, ApiKey.class)`, with `ApiKey` as a class or record whose fields match the credential's keys. The `execute` override takes the same five parameters. +- Overriding the five-parameter `execute` replaces the four-parameter one. Don't override both. +- The worker reads credentials from the credentials server at `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` (default `http://localhost:8083`). The template's local Docker stack doesn't include one, so you can't try this node end to end locally unless you run the credentials server yourself. Test it with a fake fetcher instead, as below. +- **On Kubernetes, set that variable in your chart.** The `continuum-platform` chart deploys the credentials server, but the template's `deployment.yaml` doesn't pass its address to your worker, so a credential node would look for `localhost:8083` and fail. Add this to the `env:` list in `charts//templates/deployment.yaml`, next to `CONTINUUM_API_SERVER_BASE_URL`, and adjust the host if you installed `continuum-platform` under another release name (the service is `-credentials-server`, port 8080): + + ```yaml + - name: CONTINUUM_CREDENTIALS_SERVER_BASE_URL + value: "http://continuum-platform-credentials-server:8080" + ``` +- For the platform side (how credentials are stored and fetched), see [Credentials in the node model](../../architecture/node-model.md#credentials). + +Test it by giving `ExecutionContext` a fake `CredentialFetcher`: + +```kotlin +package com.acme.demo.node + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.argumentCaptor +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever +import org.projectcontinuum.core.commons.context.CredentialFetcher +import org.projectcontinuum.core.commons.context.ExecutionContext +import org.projectcontinuum.core.commons.utils.NodeOutputWriter + +class ApiLookupNodeModelTest { + @Test + fun `reads the selected credential`() { + val outputWriter = mock() + val portWriter = mock() + whenever(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter) + val context = ExecutionContext( + ownerId = "test-user", + credentialFetcher = CredentialFetcher { name -> if (name == "my-key") mapOf("key" to "abc123") else null } + ) + + ApiLookupNodeModel().execute(mapOf("credential" to "my-key"), emptyMap(), outputWriter, mock(), context) + + val row = argumentCaptor>() + verify(portWriter).write(any(), row.capture()) + assertEquals(6, row.firstValue["key_length"]) + } +} +``` + +## Change a node's retry behaviour + +By default a failing node is retried with the workflow's retry policy. To give one node its own policy, set `retryOptions` in its metadata: + +```kotlin +override val metadata = ContinuumWorkflowModel.NodeData( + id = this.javaClass.name, + nodeModel = this.javaClass.name, + title = "API Lookup", + description = "Calls an API with a stored credential", + retryOptions = ContinuumWorkflowModel.RetryOptionsConfig(maximumAttempts = 3, initialIntervalSeconds = 5), + // … ports, properties and schemas as before +) +``` + +`RetryOptionsConfig` has five optional fields: `initialIntervalSeconds`, `backoffCoefficient`, `maximumIntervalSeconds`, `maximumAttempts` and `doNotRetry` (a list of exception type names that must never be retried). Leave a field out to keep the default. In Java, pass `null` for the `retryOptions` argument of `NodeData` to keep the workflow default, as the Word Counter does. + +A `NodeRuntimeException` with `isRetriable = false` is never retried, whatever the policy says. + +## Add a library + +The Continuum plugins already give you Spring, Jackson 3, the test libraries and SLF4J. Add anything else to the feature module's own `build.gradle.kts`, not the worker's: + +```kotlin +dependencies { + implementation("org.apache.commons:commons-text:1.12.0") +} +``` + +The worker picks it up through `implementation(project(":features:"))`. Don't add Jackson 2 artifacts; they clash with the platform's Jackson 3. + +## Log from a node + +Use SLF4J. The plugins put it on the classpath, so no dependency is needed: + +```kotlin +import org.slf4j.LoggerFactory + +private val logger = LoggerFactory.getLogger(WordCounterNodeModel::class.java) + +// inside execute(): +logger.info("Counted words in {} rows", rowNumber) +``` + +The template's `application.yaml` sets the root log level to `error` and your package to `debug`, so your `info` and `debug` lines show up in the worker's console while other libraries stay quiet. Don't log row contents or credentials. + +## Debug a node + +- **Run the worker from your IDE.** Start `App.kt` in the `worker` module with the debugger and set breakpoints in your node. The worker defaults match the local stack, so no extra configuration is needed. +- **Or attach to Gradle.** `./gradlew :worker:bootRun --debug-jvm` waits for a debugger on port 5005. +- **Run a workflow** in the Workbench to trigger the node. A breakpoint in `execute()` pauses it. Temporal may time the activity out if you stay paused for a long time, so step through quickly. +- Prefer a **unit test** when you can: it reproduces most logic bugs without Docker. Add a failing test, fix the code, keep the test. + +Next: if something doesn't work, see [Troubleshooting](./troubleshooting.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md index 1bb1f20..64e91ff 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-1-clone-and-run.md @@ -47,7 +47,11 @@ From the repository root: ./gradlew :worker:bootRun ``` -The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. +The worker connects to Temporal, registers its nodes with the platform and serves on port `8090`. Wait for these lines in its output: + +```text +Registered process nodes: [org.projectcontinuum.feature.example.node.HelloWorldNodeModel, org.projectcontinuum.feature.example.java.node.HelloJavaNodeModel] +``` ## 5. See your nodes in the Workbench diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md index 52640c7..23ee2c9 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md @@ -15,7 +15,7 @@ The template has about 40 files, but you will only write code in a handful of th ## The big picture -Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. +Your repository builds **one worker**. The worker is a small Spring Boot app that loads one or more **feature modules**. A feature module is a Gradle library that contains your node classes. The template ships two example modules, one in Kotlin and one in Java. You keep the one you write in and delete the other in [Step 3](./step-3-make-it-yours.md). ```mermaid flowchart LR @@ -56,7 +56,7 @@ continuum-feature-template/ │ │ └── …/node/HelloWorldNodeModel.doc.md Write ← help page │ └── test/kotlin/…/HelloWorldNodeModelTest.kt Write ← unit test │ -├── features/continuum-feature-hello-java/ Delete if you only write Kotlin (same layout) +├── features/continuum-feature-hello-java/ Rename once same layout in Java; delete whichever example you don't need │ ├── worker/ │ ├── build.gradle.kts Keep in sync which modules the worker loads, image name @@ -66,14 +66,15 @@ continuum-feature-template/ │ ├── charts/continuum-feature-template/ Keep in sync Helm chart for Kubernetes ├── docker/ Leave alone local Continuum stack -└── .github/workflows/ Keep in sync CI and release (lists your modules) +├── .github/workflows/ Keep in sync CI and release (lists your modules) +└── README.md, CONTRIBUTING.md, AGENTS.md Rename once still describe the template ``` ## The files that matter ### Files you write -These three live side by side in each feature module and share a name: +These three live side by side in each feature module and share a name. The Java module has the same layout, with `HelloJavaNodeModel` and `.java` files: | File | What it is | |------|------------| @@ -90,7 +91,7 @@ If you get one of the first three wrong, the build still passes but **the worker | `AutoConfigure.kt` | A small `@Configuration` + `@ComponentScan` class. It makes Spring scan your package for nodes. Your node classes must live in this package or below. If `basePackages` doesn't cover your node's package, the node isn't found. | | `META-INF/spring/…AutoConfiguration.imports` | One line naming the `AutoConfigure` class. Spring Boot reads this file to find your module. If the file is missing or names the wrong class, Spring doesn't load your module. | | `worker/build.gradle.kts` | Its `implementation(project(...))` lines decide which feature modules the worker loads. A module that isn't listed here is never loaded. | -| `node/` package name | Node classes must be in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. | +| `node/` package name | Node classes belong in a package ending in `.node`. The platform derives your **feature ID** by removing that last segment. (Other package names still load; the feature ID is then the whole package.) | If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). @@ -112,7 +113,7 @@ If a node doesn't appear after [Step 5](./step-5-test-and-run.md), follow the [c ## What the Gradle plugins do for you -You don't declare Spring, Temporal, Jackson or test dependencies. The two Continuum plugins add them: +You don't declare Spring, Temporal, Jackson or test dependencies. The three Continuum plugins add them: | Plugin | Used in | Gives you | |--------|---------|-----------| @@ -120,10 +121,6 @@ You don't declare Spring, Temporal, Jackson or test dependencies. The two Contin | `org.projectcontinuum.feature-java` | Java feature modules | The same, for Java. | | `org.projectcontinuum.worker` | `worker/` | Spring Boot, the worker starter (Temporal polling and node registration), `bootRun`, and Jib for the container image. | -Add a `dependencies { }` block to a feature module only when your node needs an extra library. - -:::info[Versions] -The template builds against Continuum platform `0.0.20` (Spring Boot 4.0.6, Kotlin 2.2, Jackson 3, Gradle 8.14, JDK 21). Everything comes from Maven Central, so you don't need a GitHub token. -::: +Add a `dependencies { }` block to a feature module only when your node needs an extra library; see [Add a library](./recipes.md#add-a-library). The plugin versions are the `continuumPlatformVersion` in `gradle.properties` (see the [version note in the overview](./overview.md#what-you-need)). Next: [rename the template](./step-3-make-it-yours.md). diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md index eb241d7..0125ac5 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-3-make-it-yours.md @@ -8,60 +8,177 @@ title: "Step 3: Make it yours" Step 3 of 6 - About 20 minutes + About 5 minutes with the script, 20 by hand -The template carries its own name in many files. This step replaces it with yours. It's tedious but mechanical, and you only do it once. Work through the checklist in order and commit when the build is green. +The template carries its own name in many files. This step replaces it with yours and removes the example module in the language you don't use. It's mechanical, and you only do it once. -Pick your values first, and check the other Continuum repositories to make sure the names aren't already in use: +You have two ways to do it: run a [script](#option-a-run-the-rename-script) that does the whole job, or work through the [manual checklist](#option-b-the-manual-checklist). Both end at the same [leftover check](#check-for-leftovers). + +## Pick your values + +Pick these first, and check the other Continuum repositories to make sure the names aren't already in use: | Placeholder | Example | Used for | Changing it later | |-------------|---------|----------|-------------------| -| `` | `continuum-feature-demo` | Repository, Gradle root project, Helm chart and Docker image name | Possible, but you repeat this whole step. | -| `` | `org.projectcontinuum.feature.demo` | Kotlin/Java package for your nodes | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | +| `` | `acme` | Your GitHub organisation or user, and your Docker Hub organisation | Easy. | +| `` | `continuum-feature-demo` | Repository, Gradle root project, feature module, Helm chart, worker and Docker image name | Possible, but you repeat this whole step. | +| `` | `com.acme.demo` | Package for your nodes (the node classes go in `.node`) | Breaks saved workflows that use your nodes, because the package is part of each node's identity. Don't change it after shipping. | | `` | `CONTINUUM_FEATURE_DEMO_TASK_QUEUE` | Temporal task queue. **Must be unique across all workers in your Continuum instance.** | Change it in `application.yaml` and the chart together. | +| `` | `featureDemo` | The key under `continuum:` in the Helm chart's values | Easy, but change it in every chart file. | + +:::warning[Pick a package you own] +Use a package that starts with a domain you control (`com.acme.demo`) or `io.github.`. Don't use `org.projectcontinuum.*`: that namespace belongs to the platform. The feature module's Maven `group` is set to your package, and **Maven Central only accepts a group whose namespace you've verified**. If you don't plan to publish your feature modules as libraries, you can ignore this and [switch publishing off in Step 6](./step-6-ship-it.md#3-add-repository-secrets). +::: + +:::danger[Pick a unique task queue now] +Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. +::: + +## Which example do you keep? + +The template ships the same Hello World node twice: `features/continuum-feature-hello` (Kotlin) and `features/continuum-feature-hello-java` (Java). Keep the one that matches the language you write and delete the other. Mixing languages in one module isn't supported by the template; if you want both, keep both modules and run through the checklist for each. + +## Option A: Run the rename script + +The script below does everything in [Option B](#option-b-the-manual-checklist) except editing the descriptions and the README. It's been tested on a fresh clone of the template for both the Kotlin and the Java variants, followed by `./gradlew build`. + +1. Commit or stash anything you changed so you can review the result with `git diff`. +2. Save the script as `rename.sh` **outside** the repository (for example in your home folder). +3. Edit the six values at the top, including `LANGUAGE`. +4. Run it from anywhere inside your clone: `bash ~/rename.sh`. + +It needs `bash` and `perl`, which macOS and Linux have. On Windows, use WSL or Git Bash. + +
+rename.sh + +```bash +#!/usr/bin/env bash +set -euo pipefail + +# ---- Edit these six values --------------------------------------------- +export ORG=acme # your GitHub organisation or user +export REPO=continuum-feature-demo # repository, module, chart and worker name +export PKG=com.acme.demo # package for your nodes (without .node) +export TASK_QUEUE=CONTINUUM_FEATURE_DEMO_TASK_QUEUE +export VALUES_KEY=featureDemo # key under `continuum:` in the Helm values +export IMAGE=acme/continuum-feature-demo # Docker image, without a tag +LANGUAGE=kotlin # kotlin or java: which example module to keep +# ------------------------------------------------------------------------- + +cd "$(git rev-parse --show-toplevel)" + +if [ "$LANGUAGE" = kotlin ]; then + KEEP=continuum-feature-hello + export OLD_PKG=org.projectcontinuum.feature.example + export DROP_RE='continuum-feature-hello-java' + export DROP_PLUGIN='id\("org\.projectcontinuum\.feature-java"\)' + DROP=continuum-feature-hello-java +else + KEEP=continuum-feature-hello-java + export OLD_PKG=org.projectcontinuum.feature.example.java + export DROP_RE='continuum-feature-hello(?!-java)' + export DROP_PLUGIN='id\("org\.projectcontinuum\.feature"\)' + DROP=continuum-feature-hello +fi +export SHORT="${REPO#continuum-}" +OLD_PATH="${OLD_PKG//.//}" +NEW_PATH="${PKG//.//}" + +# 1. Remove the example module you don't need +rm -rf "features/$DROP" +perl -ni -e 'print unless /$ENV{DROP_RE}/' \ + settings.gradle.kts worker/build.gradle.kts .github/workflows/build-module.yml +perl -ni -e 'print unless /$ENV{DROP_PLUGIN}/' settings.gradle.kts +perl -0pi -e 's/^ *- module: features:$ENV{DROP_RE}\n(?: +publish_\w+: \w+\n)+//m' \ + .github/workflows/on-release.yml + +# 2. Rename the module, package folders and chart folder +mv "features/$KEEP" "features/$REPO" +for d in src/main/kotlin src/main/java src/main/resources src/test/kotlin src/test/java; do + src="features/$REPO/$d/$OLD_PATH" + if [ -d "$src" ]; then + mkdir -p "features/$REPO/$d/$(dirname "$NEW_PATH")" + mv "$src" "features/$REPO/$d/$NEW_PATH" + fi +done +find "features/$REPO" -type d -empty -delete +mv charts/continuum-feature-template "charts/$REPO" + +# 3. Replace the template's names inside files +find . \( -name .git -o -name .gradle -o -name .kotlin -o -name build -o -name .idea \ + -o -path ./docker -o -path ./gradle \) -prune -o -type f ! -name 'gradlew*' -print0 | + xargs -0 perl -pi -e ' + s{org\.projectcontinuum\.feature\.example(\.java)?}{$ENV{PKG}}g; + s{projectcontinuum/continuum-feature-template}{$ENV{IMAGE}}g; + s{projectcontinuum-org/continuum-feature-template}{$ENV{ORG}/$ENV{REPO}}g; + s{continuum-feature-hello(-java)?}{$ENV{REPO}}g; + s{continuum-feature-template}{$ENV{REPO}}g; + s{CONTINUUM_FEATURE_TEMPLATE_TASK_QUEUE}{$ENV{TASK_QUEUE}}g; + s{featureTemplate}{$ENV{VALUES_KEY}}g; + s{feature-template}{$ENV{SHORT}}g; + ' +perl -pi -e 's{org\.projectcontinuum\.app\.worker\.example}{$ENV{PKG}.app.worker}g' worker/build.gradle.kts + +echo "Done. Still to do by hand: the description lines in build.gradle.kts and Chart.yaml, and README.md." +echo "Leftovers (expect none):" +grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ + --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . || true +``` + +
+ +When it finishes, the "Leftovers" list at the end of its output should be empty. Then finish by hand: + +- [ ] The `description` lines in `features//build.gradle.kts`, `worker/build.gradle.kts` and `charts//Chart.yaml`. The script renames words but can't rewrite a sentence. +- [ ] `README.md`, `CONTRIBUTING.md` and `AGENTS.md`: the script fixes names and links, but the text still describes the template (badges, the "Ownership" list in `AGENTS.md`, and so on). Rewrite what no longer applies. -## Checklist +Skip ahead to [Check for leftovers](#check-for-leftovers). + +## Option B: The manual checklist + +Work through this in order and commit when the build is green. `` below means the module you keep: `continuum-feature-hello` (Kotlin) or `continuum-feature-hello-java` (Java). ### 1. Project identity - [ ] `settings.gradle.kts`: set `rootProject.name = ""`. -- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. +- [ ] `gradle.properties`: set `repoName=/`. Leave the version lines as they are. + +### 2. Remove the example you don't need + +- [ ] Delete the other module's folder under `features/`. +- [ ] Remove its `include(...)` line from `settings.gradle.kts`. +- [ ] Remove its `implementation(project(...))` line from `worker/build.gradle.kts`. +- [ ] `settings.gradle.kts` also declares the Gradle plugins in `pluginManagement { plugins { … } }`. Remove the `id("org.projectcontinuum.feature-java")` line if you keep Kotlin, or the `id("org.projectcontinuum.feature")` line if you keep Java. +- [ ] `.github/workflows/on-release.yml`: delete its `- module:` entry in the matrix, including the `publish_*` lines under it. +- [ ] `.github/workflows/build-module.yml`: delete its line in the `options:` list. -### 2. The feature module +### 3. The feature module -Rename the folder `features/continuum-feature-hello/` to `features//` and then: +Rename the folder `features//` to `features//` and then: -- [ ] `settings.gradle.kts`: change `include(":features:continuum-feature-hello")` to `include(":features:")`. -- [ ] `features//build.gradle.kts`: change `group` and `description`. -- [ ] Rename the package folders under `src/main/kotlin`, `src/test/kotlin` and `src/main/resources`, from `org/projectcontinuum/feature/example` to your `` path. Update the `package` line in every file you moved. -- [ ] `AutoConfigure.kt`: update the `basePackages` value in `@ComponentScan` to ``. +- [ ] `settings.gradle.kts`: change `include(":features:")` to `include(":features:")`. +- [ ] `features//build.gradle.kts`: change `group` to `` and rewrite `description`. +- [ ] Rename the package folders under `src/main/kotlin` (or `src/main/java`), `src/test/…` and `src/main/resources`. The old path is `org/projectcontinuum/feature/example` for Kotlin and `org/projectcontinuum/feature/example/java` for Java. Replace it with your `` path. Update the `package` line in every file you moved. +- [ ] `AutoConfigure.kt` (or `AutoConfigure.java`): update the `basePackages` value in `@ComponentScan` to ``. - [ ] `META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`: change the line to `.AutoConfigure`. :::tip[Use your IDE's rename] -In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit the three text files above by hand: `AutoConfigure.kt`'s `basePackages`, the `.imports` file and the Gradle files. +In IntelliJ, use **Refactor → Rename** on the package and module folders. It updates `package` lines and imports for you. You still have to edit `basePackages`, the `.imports` file and the Gradle files by hand. ::: -### 3. Java example (optional) - -- [ ] If you only write Kotlin, delete `features/continuum-feature-hello-java/` and remove its `include(...)` from `settings.gradle.kts`, its `implementation(project(...))` from `worker/build.gradle.kts`, and its `id("org.projectcontinuum.feature-java")` line from `settings.gradle.kts`. -- [ ] If you keep it, repeat step 2 for it. - ### 4. The worker - [ ] `worker/build.gradle.kts`: - `implementation(project(":features:"))` must point at your renamed module. - - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. + - Change `jibToImage` to the image you will publish, for example `/:${project.version}`. - Change `group` and `description`. - [ ] `worker/src/main/resources/application.yaml`: - `spring.application.name` → `-worker` - the default of `node-task-queue` → `` - the `org.projectcontinuum.feature.example` log level → `` -:::danger[Pick a unique task queue now] -Every worker needs its own task queue. If two workers share one, Temporal gives a node's work to whichever worker polls first, including one that doesn't have that node, and the node fails at random. Search the other Continuum repositories before you pick a name. -::: - ### 5. The Helm chart The chart folder, its helper templates and its values keys all carry the template's name. Replace them together or Helm will fail with "template not found". @@ -69,31 +186,31 @@ The chart folder, its helper templates and its values keys all carry the templat - [ ] Rename `charts/continuum-feature-template/` to `charts//`. - [ ] `Chart.yaml`: change `name`, `description` and `home`. - [ ] `values.yaml` and `values-dev.yaml`: - - the `featureTemplate:` key → a name for your worker (for example `featureDemo:`) + - the `featureTemplate:` key → `` - `image.repository` → your image from `jibToImage` - `taskQueue` → `` (**the same value as in `application.yaml`**) -- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with your new values key, and the `feature-template` component label with your own. +- [ ] `templates/*.yaml`, `templates/_helpers.tpl` and `templates/NOTES.txt`: replace every `continuum-feature-template` with ``, every `.featureTemplate.` with `..`, and the `feature-template` component label with your own. - [ ] `Chart.yaml` `appVersion` must equal `featureVersion` in `gradle.properties` (both `0.0.1` as shipped). ### 6. CI and release workflows -- [ ] `.github/workflows/on-release.yml`: update the `module:` entries in the matrix to your module names. -- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module names. +- [ ] `.github/workflows/on-release.yml`: update the `module:` entry for your module in the matrix. +- [ ] `.github/workflows/build-module.yml`: update the `options:` list to your module name. ### 7. Text files -- [ ] `README.md` and `CONTRIBUTING.md`: replace the template's name, badges and links. +- [ ] `README.md`, `CONTRIBUTING.md` and `AGENTS.md`: replace the template's name, badges, links and descriptions. ## Check for leftovers -Run this from the repository root. It should print nothing when you're done: +Run this from the repository root. It prints nothing when every rename is done: ```bash grep -rIn "feature-template\|featureTemplate\|FEATURE_TEMPLATE\|feature\.example\|feature-hello" \ --exclude-dir=.git --exclude-dir=.gradle --exclude-dir=.kotlin --exclude-dir=build . ``` -If you kept the Java example or its folder name, `feature-hello` will still match; that's fine. Anything else is a missed rename. +Any line it prints is a missed rename. (`AGENTS.md` and `README.md` are the files most often missed.) Then confirm nothing broke: @@ -103,18 +220,19 @@ Then confirm nothing broke: If you changed the chart, also run `helm lint charts/`. +At this point the build contains the template's **Hello World** node under your name. That's expected: you replace it in the next step. + ### Before you move on - [ ] The module folder, the `include(...)` line in `settings.gradle.kts` and the `implementation(project(...))` line in `worker/build.gradle.kts` all use the same module name. - [ ] The `.imports` file names your real `AutoConfigure` class. -- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml` (if you updated the chart). -- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml` (if you updated the chart). +- [ ] `node-task-queue` in `application.yaml` equals `taskQueue` in the chart's `values.yaml`. +- [ ] `featureVersion` in `gradle.properties` equals `appVersion` in `Chart.yaml`. - [ ] The leftover grep above prints nothing. -- [ ] `./gradlew build` passes, and `helm lint charts/` passes if you changed the chart. +- [ ] `./gradlew build` passes, and `helm lint charts/` passes. :::info[What you can skip for now] -You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need sections 1 to 4. +You can postpone the Helm chart and the workflow files until you are ready to deploy ([Step 6](./step-6-ship-it.md)). The build, tests and local run only need the project, module and worker sections. If you postpone them, the leftover grep will still report the chart and workflows. ::: Next: [write your node](./step-4-write-your-node.md). - diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md index 7e001cb..8c2a345 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-4-write-your-node.md @@ -4,6 +4,9 @@ sidebar_label: "4. Write your node" title: "Step 4: Write your node" --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # Step 4: Write your node @@ -11,7 +14,9 @@ title: "Step 4: Write your node" About 30 minutes -You don't start from a blank file. Rename the template's **Hello World** node and change what it does. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. +You don't start from a blank file. Take the template's **Hello World** node (or **Hello Java**) and **rewrite it** into your own: rename the files and the class, then replace the ports, settings and logic. The running example here is a **Word Counter** that counts the words in a text column and appends the count as a new column. + +Every code sample on this page was compiled and its tests were run against platform `0.0.20`. Pick your language in the tabs; the choice sticks across the page. A node is three files that share a name. Do them in this order: @@ -19,13 +24,15 @@ A node is three files that share a name. Do them in this order: 2. [The help page](#2-the-help-page) 3. [The unit test](#3-the-unit-test) +Once those work, [More node recipes](./recipes.md) shows how to add a second node, write a source node, use credentials and more. + ## 1. The node class -Rename `HelloWorldNodeModel.kt` to `WordCounterNodeModel.kt` (and the class inside it). The file has six parts. Only the numbered ones need your changes: +Rename `HelloWorldNodeModel.kt` (Java: `HelloJavaNodeModel.java`) to `WordCounterNodeModel.kt` (or `.java`) and the class inside it, then replace the contents. The class has six parts: ```text @ContinuumNode ← required, never remove -class WordCounterNodeModel(...) : ProcessNodeModel() { +class WordCounterNodeModel : ProcessNodeModel() { 1. ports what goes in and out 2. categories where it appears in the palette 3. propertiesSchema what settings exist, and what is valid @@ -35,10 +42,13 @@ class WordCounterNodeModel(...) : ProcessNodeModel() { } ``` -Here is the finished Word Counter, with the six parts marked: +Here is the finished Word Counter, with the six parts marked. It lives in the package `.node`, which is `com.acme.demo.node` in this example: + + + ```kotlin -package org.projectcontinuum.feature.demo.node +package com.acme.demo.node import org.projectcontinuum.core.commons.annotation.ContinuumNode import org.projectcontinuum.core.commons.exception.NodeRuntimeException @@ -58,12 +68,12 @@ class WordCounterNodeModel( private val whitespace = Regex("\\s+") - // 1. Ports. The map keys ("data") are the port IDs you use in execute(). + // 1. Ports. The map keys ("input", "output") are the port IDs you use in execute(). final override val inputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) + "input" to ContinuumWorkflowModel.NodePort(name = "Input Table", contentType = APPLICATION_OCTET_STREAM_VALUE) ) final override val outputPorts = mapOf( - "data" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) + "output" to ContinuumWorkflowModel.NodePort(name = "Table with word counts", contentType = APPLICATION_OCTET_STREAM_VALUE) ) // 2. Palette category @@ -128,12 +138,12 @@ class WordCounterNodeModel( ?: throw NodeRuntimeException(isRetriable = false, workflowId = "", nodeId = "", message = "outputCol is not provided") val minWordLength = (properties["minWordLength"] as Number?)?.toInt() ?: 1 - val reader = inputs["data"] ?: throw NodeRuntimeException( - isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'data' is not connected" + val reader = inputs["input"] ?: throw NodeRuntimeException( + isRetriable = false, workflowId = "", nodeId = "", message = "Input port 'input' is not connected" ) val totalRows = reader.getRowCount() - nodeOutputWriter.createOutputPortWriter("data").use { writer -> + nodeOutputWriter.createOutputPortWriter("output").use { writer -> reader.use { var rowNumber = 0L while (true) { @@ -151,6 +161,152 @@ class WordCounterNodeModel( } ``` + + + +```java +package com.acme.demo.node; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.projectcontinuum.core.commons.annotation.ContinuumNode; +import org.projectcontinuum.core.commons.exception.NodeRuntimeException; +import org.projectcontinuum.core.commons.model.ContinuumWorkflowModel; +import org.projectcontinuum.core.commons.node.ProcessNodeModel; +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback; +import org.projectcontinuum.core.commons.utils.NodeInputReader; +import org.projectcontinuum.core.commons.utils.NodeOutputWriter; +import org.springframework.http.MediaType; +import tools.jackson.core.type.TypeReference; +import tools.jackson.databind.ObjectMapper; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@ContinuumNode +public class WordCounterNodeModel extends ProcessNodeModel { + + private static final ObjectMapper MAPPER = new ObjectMapper(); + private static final TypeReference> MAP_TYPE = new TypeReference<>() {}; + + // 1. Ports. The map keys ("input", "output") are the port IDs you use in execute(). + private final Map inputPorts = Map.of( + "input", new ContinuumWorkflowModel.NodePort("Input Table", MediaType.APPLICATION_OCTET_STREAM_VALUE)); + private final Map outputPorts = Map.of( + "output", new ContinuumWorkflowModel.NodePort("Table with word counts", MediaType.APPLICATION_OCTET_STREAM_VALUE)); + + @NotNull @Override public Map getInputPorts() { return inputPorts; } + @NotNull @Override public Map getOutputPorts() { return outputPorts; } + + // 2. Palette category + @NotNull @Override public List getCategories() { return List.of("Demo"); } + + // 3. JSON Schema: the settings and their rules + private static final Map PROPERTIES_SCHEMA = MAPPER.readValue(""" + { + "type": "object", + "properties": { + "inputCol": { "type": "string", "title": "Input Column" }, + "outputCol": { "type": "string", "title": "Output Column" }, + "minWordLength": { "type": "integer", "title": "Minimum Word Length", "minimum": 1, "default": 1 } + }, + "required": ["inputCol", "outputCol"] + } + """, MAP_TYPE); + + // 4. JSON Forms UI schema: the layout of the settings form + private static final Map PROPERTIES_UI_SCHEMA = MAPPER.readValue(""" + { + "type": "VerticalLayout", + "elements": [ + { "type": "Control", "scope": "#/properties/inputCol" }, + { "type": "Control", "scope": "#/properties/outputCol" }, + { "type": "Control", "scope": "#/properties/minWordLength" } + ] + } + """, MAP_TYPE); + + // 5. Metadata. Java has no default arguments, so pass all 15 parameters in order. + private final ContinuumWorkflowModel.NodeData metadata = new ContinuumWorkflowModel.NodeData( + getClass().getName(), // id + "Counts the words in a text column and appends the count as a new column", // description + "Word Counter", // title + "Count words per row", // subTitle + null, // icon (SVG string, or null) + getClass().getName(), // nodeModel + null, // busy + inputPorts, // inputs + outputPorts, // outputs + Map.of("inputCol", "text", "outputCol", "word_count", "minWordLength", 1), // default settings + PROPERTIES_SCHEMA, // propertiesSchema + PROPERTIES_UI_SCHEMA, // propertiesUISchema + null, // status + null, // nodeProgress + null // retryOptions (null = workflow default) + ); + + @NotNull @Override public ContinuumWorkflowModel.NodeData getMetadata() { return metadata; } + + // 6. The logic + @Override + public void execute( + @Nullable Map properties, + @NotNull Map inputs, + @NotNull NodeOutputWriter nodeOutputWriter, + @NotNull NodeProgressCallback nodeProgressCallback + ) { + String inputCol = requireString(properties, "inputCol"); + String outputCol = requireString(properties, "outputCol"); + Object min = properties.get("minWordLength"); + int minWordLength = (min instanceof Number n) ? n.intValue() : 1; + + NodeInputReader reader = inputs.get("input"); + if (reader == null) { + throw new NodeRuntimeException(false, "", "", "Input port 'input' is not connected"); + } + long totalRows = reader.getRowCount(); + long rowNumber = 0; + + NodeOutputWriter.OutputPortWriter writer = nodeOutputWriter.createOutputPortWriter("output"); + try { + Map row; + while ((row = reader.read()) != null) { + Object cell = row.get(inputCol); + String text = cell == null ? "" : cell.toString().trim(); + int count = 0; + if (!text.isEmpty()) { + for (String word : text.split("\\s+")) { + if (word.length() >= minWordLength) count++; + } + } + Map out = new HashMap<>(row); + out.put(outputCol, count); + writer.write(rowNumber, out); + rowNumber++; + if (totalRows > 0) nodeProgressCallback.report((int) (rowNumber * 100 / totalRows)); + } + } finally { + writer.close(); + reader.close(); + } + } + + private static String requireString(Map properties, String key) { + Object value = properties == null ? null : properties.get(key); + if (!(value instanceof String s)) { + throw new NodeRuntimeException(false, "", "", key + " is not provided"); + } + return s; + } +} +``` + +In Java the three overrides `getInputPorts()`, `getOutputPorts()` and `getCategories()` replace Kotlin's `override val` properties, and the `@NotNull` / `@Nullable` annotations match the Kotlin signatures. The 15 arguments to `NodeData` are in the order shown by the comments. + + + + ### Rules the platform enforces Break one of these and the build fails, the node doesn't load, or workflows break later. @@ -158,37 +314,45 @@ Break one of these and the build fails, the node doesn't load, or workflows brea | Rule | Why | |------|-----| | Annotate with `@ContinuumNode`, not `@Component`. | It makes the bean prototype-scoped, so each run gets a fresh instance. The build fails without it (`validateContinuumNodeAnnotations`). | -| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. | -| Set `metadata.id` and `metadata.nodeModel` to `this.javaClass.name`. | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | -| Put the class in a package that ends in `.node`. | The platform removes that last segment to get the feature ID. | +| Extend `ProcessNodeModel` (has inputs) or `TriggerNodeModel` (source node, outputs only). | `TriggerNodeModel.execute()` has no `inputs` parameter. See [a source node](./recipes.md#a-source-node-with-no-inputs). | +| Set `metadata.id` and `metadata.nodeModel` to the class's full name (`this.javaClass.name` / `getClass().getName()`). | The full class name is the node's identity in saved workflows. **Renaming or moving the class later breaks workflows that use it.** | +| Put the class in a package that ends in `.node`. | By convention. The platform removes that last segment to get the feature ID (`com.acme.demo.node` → `com.acme.demo`). Without it, the whole package name becomes the feature ID, and the node still loads. | | Import Jackson from `tools.jackson.*`. | The platform uses Jackson 3. `com.fasterxml.jackson.*` (Jackson 2) won't compile. | -| Take `ObjectMapper` as a constructor parameter. | Spring injects it. In unit tests, pass `jacksonObjectMapper()`. | + +Two notes on `ObjectMapper`: + +- In Kotlin you can take it as a constructor parameter and Spring injects it. In unit tests, pass `jacksonObjectMapper()`. +- In Java, the example creates a `static` mapper, which works because the schemas are built once when the class loads. You can also take an `ObjectMapper` in a constructor, as in Kotlin. + +If you'd rather not parse JSON strings at all, you can write the schemas as nested `mapOf(...)` / `Map.of(...)` values. The [source node](./recipes.md#a-source-node-with-no-inputs) recipe does that. ### Ports `inputPorts` and `outputPorts` are maps: -- The **key** (for example `"data"`) is the port ID you use in `execute()` to read or write data. +- The **key** (here `"input"` and `"output"`) is the port ID you use in `execute()` to read or write data. The template's Hello World node uses the same two IDs, so the rest of the platform's examples look familiar. - The **value** is a `ContinuumWorkflowModel.NodePort` with a `name` (shown in the Workbench) and a `contentType`. Table ports use `APPLICATION_OCTET_STREAM_VALUE`, as in the running example. The template's example nodes do the same. +A node can have **several ports**. Add more entries to the map, give each a different key, and use those keys in `inputs["…"]` and `createOutputPortWriter("…")`. A node with two inputs (for example `"left"` and `"right"`) gets both readers in the `inputs` map; check each key you need, because a port that isn't connected is missing from the map. + ### Settings and validation - `properties` in the metadata holds the **default values** used when a user drops the node on the canvas. - Before `execute()` runs, the platform checks the user's settings against `propertiesSchema`. Values that break `required`, `type` or `minimum` fail the node before your code starts. Checking again in `execute()` is still worthwhile because it lets you give a clearer error message. -- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](../../architecture/node-model.md#credentials). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. +- `propertiesUiSchema` is a [JSON Forms](https://jsonforms.io/) layout, used only to draw the form. For credential pickers, see [Credentials](./recipes.md#use-a-credential). You can try schemas in the [JSON Forms playground](https://github.com/projectcontinuum-org/continuum-jsonform-playground) first. ### Reading and writing rows -- `inputs["data"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. -- `createOutputPortWriter("data")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. -- Wrap both in `.use { }`. The output file is only complete once the writer is closed. +- `inputs["input"]` is a `NodeInputReader`. `read()` returns the next row as a `Map`, or `null` at the end. If a port isn't connected, its key is missing from `inputs`. +- `createOutputPortWriter("output")` returns a writer. `write(rowNumber, row)` takes a `Long` row number that **starts at 0**. +- Close both when you are done: Kotlin's `.use { }` or Java's `try { … } finally { … }`. The output file is only complete once the writer is closed. Cell values must be one of these types, and never `null`. Anything else makes `write()` throw `IllegalArgumentException: Unsupported type`. Leave a key out instead of storing `null`. -| Kotlin type | Stored as | -|-------------|-----------| +| Kotlin / Java type | Stored as | +|--------------------|-----------| | `String` | `application/vnd.continuum.x-string` | | `Int`, `Long` | `application/vnd.continuum.x-int`, `x-long` | | `Float`, `Double` | `application/vnd.continuum.x-float`, `x-double` | @@ -200,23 +364,25 @@ Convert anything else first. For example, call `toString()` on a `LocalDate`, an ### Errors, retries and progress -Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` for errors a retry can't fix, such as: +Every node runs as a Temporal activity, so an exception thrown from `execute()` is **retried** by default (with exponential backoff). Throw `NodeRuntimeException(isRetriable = false, ...)` (Java: `new NodeRuntimeException(false, "", "", message)`) for errors a retry can't fix, such as: - Missing or invalid settings (user error) - An unconnected input port - Invalid input data that can't be recovered from Empty strings are fine for `workflowId` and `nodeId` in the exception. +To change the retry behaviour of one node, see [per-node retry options](./recipes.md#change-a-nodes-retry-behaviour). + Call `nodeProgressCallback.report(percent)` (0 to 100) as you go. The Workbench shows it as live progress on the node. ## 2. The help page -Rename `HelloWorldNodeModel.doc.md` to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. +Rename `HelloWorldNodeModel.doc.md` (Java: `HelloJavaNodeModel.doc.md`) to `WordCounterNodeModel.doc.md` and rewrite it. The Workbench shows this file next to the node. -The path must match the node's package and class name exactly. For the class `org.projectcontinuum.feature.demo.node.WordCounterNodeModel`, the file is: +The path must match the node's package and class name exactly. For the class `com.acme.demo.node.WordCounterNodeModel`, the file is: ```text -src/main/resources/org/projectcontinuum/feature/demo/node/WordCounterNodeModel.doc.md +src/main/resources/com/acme/demo/node/WordCounterNodeModel.doc.md ``` To build the path, take the class's full name, replace each `.` with `/` and add `.doc.md`. The `node` folder is part of the package, not an extra segment. @@ -227,9 +393,28 @@ A good help page has four parts, as in the template's Hello World page: what the ## 3. The unit test -Rename `HelloWorldNodeModelTest.kt` to `WordCounterNodeModelTest.kt`. Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. +Rename `HelloWorldNodeModelTest.kt` (Java: `HelloJavaNodeModelTest.java`) to `WordCounterNodeModelTest.kt` (or `.java`). Nodes are plain classes, so you can test `execute()` with Mockito mocks. No Spring, Kafka or Docker is needed. + + + ```kotlin +package com.acme.demo.node + +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertThrows +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.mockito.kotlin.any +import org.mockito.kotlin.argumentCaptor +import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever +import org.projectcontinuum.core.commons.exception.NodeRuntimeException +import org.projectcontinuum.core.commons.utils.NodeInputReader +import org.projectcontinuum.core.commons.utils.NodeOutputWriter +import tools.jackson.module.kotlin.jacksonObjectMapper + class WordCounterNodeModelTest { private val outputWriter = mock() private val portWriter = mock() @@ -237,14 +422,14 @@ class WordCounterNodeModelTest { @BeforeEach fun setUp() { - whenever(outputWriter.createOutputPortWriter("data")).thenReturn(portWriter) + whenever(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter) } @Test fun `counts words and keeps original columns`() { val reader = mockReader(listOf(mapOf("id" to 1, "text" to "the quick brown fox"))) - node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("data" to reader), outputWriter, mock()) + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), mapOf("input" to reader), outputWriter, mock()) val rows = argumentCaptor>() verify(portWriter).write(any(), rows.capture()) @@ -252,6 +437,28 @@ class WordCounterNodeModelTest { assertEquals(1, rows.firstValue["id"]) } + @Test + fun `ignores words shorter than the minimum length`() { + val reader = mockReader(listOf(mapOf("text" to "a quick brown fox"))) + + node.execute( + mapOf("inputCol" to "text", "outputCol" to "word_count", "minWordLength" to 4), + mapOf("input" to reader), outputWriter, mock() + ) + + val rows = argumentCaptor>() + verify(portWriter).write(any(), rows.capture()) + assertEquals(2, rows.firstValue["word_count"]) + } + + @Test + fun `fails without retry when the input port is not connected`() { + val error = assertThrows(NodeRuntimeException::class.java) { + node.execute(mapOf("inputCol" to "text", "outputCol" to "word_count"), emptyMap(), outputWriter, mock()) + } + assertEquals(false, error.isRetriable) + } + private fun mockReader(rows: List>): NodeInputReader { val iterator = rows.iterator() return mock().also { r -> @@ -262,7 +469,66 @@ class WordCounterNodeModelTest { } ``` -The template's `HelloWorldNodeModelTest` has more cases to copy, including metadata checks and progress reporting. + + + +```java +package com.acme.demo.node; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.projectcontinuum.core.commons.protocol.progress.NodeProgressCallback; +import org.projectcontinuum.core.commons.utils.NodeInputReader; +import org.projectcontinuum.core.commons.utils.NodeOutputWriter; + +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.*; + +class WordCounterNodeModelTest { + + private final NodeOutputWriter outputWriter = mock(NodeOutputWriter.class); + private final NodeOutputWriter.OutputPortWriter portWriter = mock(NodeOutputWriter.OutputPortWriter.class); + private final WordCounterNodeModel node = new WordCounterNodeModel(); + + @BeforeEach + void setUp() { + when(outputWriter.createOutputPortWriter("output")).thenReturn(portWriter); + } + + @Test + @SuppressWarnings("unchecked") + void countsWordsAndKeepsOriginalColumns() { + NodeInputReader reader = mockReader(List.of(Map.of("id", 1, "text", "the quick brown fox"))); + + node.execute( + Map.of("inputCol", "text", "outputCol", "word_count"), + Map.of("input", reader), outputWriter, mock(NodeProgressCallback.class)); + + ArgumentCaptor> row = ArgumentCaptor.forClass(Map.class); + verify(portWriter).write(anyLong(), row.capture()); + assertEquals(4, row.getValue().get("word_count")); + assertEquals(1, row.getValue().get("id")); + } + + private NodeInputReader mockReader(List> rows) { + var iterator = rows.iterator(); + NodeInputReader reader = mock(NodeInputReader.class); + when(reader.read()).thenAnswer(i -> iterator.hasNext() ? iterator.next() : null); + when(reader.getRowCount()).thenReturn((long) rows.size()); + return reader; + } +} +``` + + + + +The template's Hello World test has more cases to copy, including metadata checks and progress reporting. :::note These tests call `execute()` directly, so they skip the schema validation. To test validation as well, build a `ContinuumWorkflowModel.Node` and call `node.run(...)` instead. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md index 25961da..7d87478 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-5-test-and-run.md @@ -39,13 +39,22 @@ Make sure the local stack from Step 1 is still up (`docker compose ps` in `docke ## 3. Check the node was loaded -Ask the worker which nodes it serves: +The worker logs every node it found when it starts. Look for these two lines in the `bootRun` output: + +```text +Registered process nodes: [com.acme.demo.node.WordCounterNodeModel] +Registered trigger nodes: [] +``` + +Your node's full class name should be in the list. You can also ask the worker over HTTP: ```bash curl http://localhost:8090/api/v1/node-repo ``` -Your **Word Counter** should be in the response. If it isn't, the build passed but the worker didn't find your node. Follow the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). It covers the four usual causes: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class, `@ComponentScan` doesn't cover your package, or the class is missing `@ContinuumNode`. +Your **Word Counter** should be in the response. + +If it isn't, the build passed but the worker didn't find your node. Work through the [checklist in Troubleshooting](./troubleshooting.md#my-node-doesnt-show-up-in-the-workbench). Most often, one of these is wrong: the module isn't listed in `worker/build.gradle.kts`, the `.imports` file names the wrong class or `@ComponentScan` doesn't cover your package. (A missing `@ContinuumNode` is rarely the cause, because the build catches it.) ## 4. Run it in the Workbench diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md index 096ea14..7b8bdbc 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md @@ -11,7 +11,7 @@ title: "Step 6: Ship it" Needs repository secrets -Shipping is mostly already set up in the template. This page explains what each piece does and what you need to provide. +Shipping is mostly already set up in the template. This page explains what each piece does, what you need to provide and how to install the result. ## The release flow @@ -27,7 +27,7 @@ flowchart TB G --> H["GitHub release triggers workflows"] H --> I["Feature modules to Maven Central"] H --> J["Worker image to Docker Hub"] - H --> K["Helm chart to gh-pages"] + H --> K["Helm chart attached to the release
and added to the gh-pages index"] ``` :::warning[Publish a GitHub Release] @@ -53,6 +53,8 @@ featureVersion=0.0.2 appVersion: "0.0.2" # Must match gradle.properties ``` +The Docker image tag defaults to the chart's `appVersion`, so the chart installs exactly the image built from the same release. + ## 2. What CI runs | Workflow | When | What it does | @@ -62,7 +64,7 @@ appVersion: "0.0.2" # Must match gradle.properties | `lint-test.yml` | PR touching `charts/` | `ct lint` on the Helm chart | | `build-module.yml` | Manual | Build one module, optionally publish it | | `on-release.yml` | GitHub release published | Libraries → Maven Central, worker → Docker Hub | -| `release.yml` | GitHub release published | Package the Helm chart and update the `gh-pages` index | +| `release.yml` | GitHub release published | Attach the packaged Helm chart to the release and update the `gh-pages` index | :::info[Workflows are triggered by a published release] `on-release.yml` and `release.yml` run when you **publish a GitHub Release** (Repository → Releases → Create a new release). Pushing a tag or merging to `main` doesn't trigger them. @@ -76,34 +78,106 @@ The release workflows read these from your repository's **Settings → Secrets a |--------|----------|-----------| | `MAVEN_CENTRAL_USERNAME`, `MAVEN_CENTRAL_PASSWORD` | Publishing libraries to Maven Central | If publishing to Maven Central | | `GPG_KEY_ID`, `GPG_PASSPHRASE`, `GPG_SECRET_KEY`, `GPG_PUBLIC_KEY` | Signing the published artifacts | If publishing to Maven Central | -| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, always needed | +| `DOCKER_HUB_USERNAME`, `DOCKER_HUB_PASSWORD` | Pushing the worker image | Yes, unless you change the image registry (see [below](#4-where-the-image-goes)) | + +### Publishing libraries to Maven Central + +Maven Central only accepts artifacts whose `group` is a namespace you have **verified** in the Central Portal. Your feature module's `group` is your `` (for example `com.acme.demo`), so verify `com.acme.demo`'s parent domain (`com.acme`) or use `io.github.`. The Central Portal's namespace documentation explains the DNS or GitHub proof. :::tip[Not publishing libraries?] -If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets. In each feature module's `continuum { }` block set `publishToMavenCentral.set(false)`, and set `publish_to_maven: false` for those modules in `on-release.yml`. +If your nodes only run in your own worker, you don't need Maven Central or the GPG secrets, and you don't need a verified namespace. Do both of these: -You still need Docker Hub secrets to publish the worker image. +1. In each feature module's `continuum { }` block, add `publishToMavenCentral.set(false)`. +2. In `.github/workflows/on-release.yml`, set `publish_to_maven: false` for those modules. + +Otherwise the release workflow tries to publish and fails on the missing secrets or namespace. ::: -## 4. Verify before deployment +## 4. Where the image goes + +The worker image is built with Jib, so you don't need a Dockerfile and the CI runner doesn't need Docker. The target is `jibToImage` in `worker/build.gradle.kts`: + +```kotlin +continuum { + continuumVersion.set(continuumPlatformVersion) + jibToImage.set("acme/continuum-feature-demo:${project.version}") +} +``` + +`on-release.yml` runs `./gradlew :worker:jib`, which pushes that image using the `DOCKER_REPO_USERNAME` and `DOCKER_REPO_PASSWORD` environment variables. The workflow fills them from `DOCKER_HUB_USERNAME` and `DOCKER_HUB_PASSWORD`. + +To use **another registry** (GitHub Container Registry, a private registry), put its full address in `jibToImage` (for example `ghcr.io/acme/continuum-feature-demo:${project.version}`), keep the same environment variable names, and change the `env:` lines of the "Push container image" step in `on-release.yml` to read your registry's credentials. Also change `image.repository` in the chart's `values.yaml` to match. + +If the registry is **private**, your cluster needs a pull secret. The template chart's `global.imagePullSecrets` value exists, but the Deployment template doesn't use it yet. Add this under `spec.template.spec` in `charts//templates/deployment.yaml`: + +```yaml + {{- with .Values.global.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} +``` + +Then create the secret in the namespace (`kubectl create secret docker-registry …`) and list it in `values.yaml`: + +```yaml +global: + imagePullSecrets: + - name: my-registry-secret +``` -Before installing the chart to Kubernetes, verify these critical synchronization points: +## 5. Configure the chart + +The chart wires your worker to the rest of the platform through the `continuum:` block in `values.yaml`. Three parts of it need your attention: + +| Values | What it is | When to change it | +|--------|-----------|-------------------| +| `continuum.infra.*` | Addresses of the shared services: Temporal (`host`, `port`, `namespace`), Kafka (`brokerList`), the schema registry (`url`) and MinIO (`endpoint`). | If you didn't install the `continuum-infra` chart under its default release name `continuum-infra`. Each address contains that release name. | +| `continuum.secrets.existingMinioSecret` | The name of the Kubernetes Secret that holds MinIO's `root-user` and `root-password`. Your chart doesn't create it; the `continuum-platform` chart does, named `-minio-secret`. | If you installed `continuum-platform` under a name other than `continuum-platform`. | +| `continuum.apiServer` | `host` and `port` of the platform's API server, where your worker registers its nodes. The default is the service `continuum-platform-api-server` on port 8080. | Same: if the release name differs. | + +Find the real service and secret names in your cluster with: + +```bash +kubectl get svc,secret -n continuum +``` + +Your worker's own settings are under `continuum.` (`image`, `replicas`, `taskQueue`, `resources`, `autoscaling`). + +## 6. Verify before deployment + +Before installing the chart, check the points that must agree: - [ ] `taskQueue` in `charts//values.yaml` matches `node-task-queue` in `application.yaml` - [ ] `taskQueue` is globally unique (search other workers) -- [ ] `image.repository` in values.yaml matches what your release pushes to Docker Hub -- [ ] The `continuum.infra.*` and `apiServer` hosts match the release names of other Continuum services +- [ ] `image.repository` in `values.yaml` matches what your release pushes +- [ ] The `continuum.infra.*`, `secrets.existingMinioSecret` and `apiServer` values match the release names in your cluster (see above) +- [ ] `helm lint charts/` passes + +## 7. Install -Then install: +You can install from your working copy, or from the chart your release published. + +**From the repository (good for a first test):** ```bash helm install ./charts/ -n continuum ``` -See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup. +**From your release:** the `release.yml` workflow attaches the packaged chart (`-.tgz`) to the GitHub release and adds it to the Helm index on your `gh-pages` branch. Enable GitHub Pages for the `gh-pages` branch in your repository settings (**Settings → Pages**), then: + +```bash +helm repo add https://.github.io/ +helm repo update +helm install / -n continuum +``` + +For a private repository the index isn't publicly readable. Download the `.tgz` from the release and run `helm install ./-0.0.2.tgz -n continuum` instead. + +To roll out a new version, publish a new release and run `helm upgrade`. See [Deployment](../../deployment/helm-charts.md) for the full Kubernetes setup, and confirm the result by looking for your nodes in the Workbench, or check the worker's log for `Registered process nodes: [...]`. ## Worker configuration reference -You don't need to set Kafka, MinIO or the API server addresses; the worker starter ships defaults that match the local stack. Override them with environment variables when you deploy elsewhere: +You don't need to set Kafka, MinIO or the API server addresses locally; the worker starter ships defaults that match the local stack. In Kubernetes, the chart sets these for you from `values.yaml`. Override them with environment variables when you deploy some other way: | Variable | Default | Purpose | |----------|---------|---------| @@ -115,7 +189,7 @@ You don't need to set Kafka, MinIO or the API server addresses; the worker start | `CONTINUUM_KAFKA_MAIN_SCHEMA_REGISTRY` | `http://localhost:38080` | Schema registry | | `CONTINUUM_MINIO_ENDPOINT` | `http://localhost:39000` | Object storage for node data | | `CONTINUUM_MINIO_USERNAME` / `_PASSWORD` | `minioadmin` | MinIO credentials | -| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()` | +| `CONTINUUM_CREDENTIALS_SERVER_BASE_URL` | `http://localhost:8083` | Only for nodes that call `getCredential()`. The template chart doesn't set it; see [Use a credential](./recipes.md#use-a-credential). | | `CONTINUUM_CACHE_STORAGE_PATH` | `./.continuum-cache/workflow-data` | Local scratch folder | | `SERVER_PORT` | `8090` | Worker HTTP port (8080 belongs to the API server) | diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md index 22e6950..8f48af6 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/troubleshooting.md @@ -1,5 +1,5 @@ --- -sidebar_position: 8 +sidebar_position: 9 sidebar_label: Troubleshooting title: Troubleshooting --- @@ -10,35 +10,58 @@ title: Troubleshooting The build passes but your node isn't in the palette. Work down this list in order. -1. **Is the worker running and registered?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. If your node is in the response, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy. If it isn't in the response, continue with the checks below. -2. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: +1. **Did the worker find the node?** Look at the `bootRun` output for the line `Registered process nodes: [...]` (or `Registered trigger nodes: [...]` for a source node). If your class is listed, the worker is fine and the problem is on the Workbench or platform side: refresh the page and check that the local stack is healthy (`docker compose ps` in `docker/`). If the list is empty or your class is missing, continue with the checks below. +2. **Is the worker registered with the API server?** Open [http://localhost:8090/actuator/health](http://localhost:8090/actuator/health), then run `curl http://localhost:8090/api/v1/node-repo`. The worker must be able to reach the API server (`CONTINUUM_API_SERVER_BASE_URL`, default `http://localhost:8080`). +3. **Is the module on the worker?** `worker/build.gradle.kts` needs `implementation(project(":features:"))`: ```bash grep "implementation(project" worker/build.gradle.kts ``` -3. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: +4. **Does the `.imports` file name your `AutoConfigure` class?** The file is in your **feature module**, not the worker: ```bash cat features//src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports ``` It must contain exactly `.AutoConfigure`. -4. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt`, `basePackages` must include your node's package. The node class must be in that package or below. -5. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. The build fails without it, so if `./gradlew build` passed, this is rarely the cause. +5. **Does `@ComponentScan` cover your node?** In `features//src/main/kotlin//AutoConfigure.kt` (or `src/main/java/…/AutoConfigure.java`), `basePackages` must include your node's package. The node class must be in that package or below. +6. **Is the class annotated?** It needs `@ContinuumNode`, not `@Component`. `./gradlew build` fails without it (`validateContinuumNodeAnnotations`), so if the build passed, this is rarely the cause. After fixing any of these, rebuild and restart the worker. Reloading the browser isn't enough. -Still not appearing? Check that the node's package ends in `.node`, that the build output has no compilation errors, and that the local stack is healthy (`docker compose ps` in `docker/`). As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. +If it is still missing, check that the build output has no compilation errors and that the local stack is healthy. As a last resort, stop the worker, run `docker compose restart` in `docker/`, and start the worker again. Avoid `docker compose down -v`: it deletes the stack's data volumes. -## Errors +## My node appears but fails when it runs + +- Look at the worker console (the `bootRun` output). Your `execute()` exception and stack trace are there. +- A node that fails and then runs again is being **retried**. If the cause can't change between attempts (bad settings, an unconnected port), throw `NodeRuntimeException(isRetriable = false, …)`; see [Errors, retries and progress](./step-4-write-your-node.md#errors-retries-and-progress). +- Reproduce it in a unit test with the same settings and input rows. This is faster than rerunning a workflow. + +## Build and start-up errors | Symptom | Cause and fix | |---------|---------------| | `Plugin [id: 'org.projectcontinuum.worker', version: '…'] was not found` | `continuumPlatformVersion` in `gradle.properties` isn't a released version on Maven Central, or `mavenCentral()` is missing from `pluginManagement.repositories` in `settings.gradle.kts`. | | `Unresolved reference 'databind'` / `'ObjectMapper'` | Jackson 2 imports. Use `tools.jackson.core.type.TypeReference` and `tools.jackson.databind.ObjectMapper`, not `com.fasterxml.jackson.*`. | | `validateContinuumNodeAnnotations FAILED` | A class extends `ProcessNodeModel` or `TriggerNodeModel` without `@ContinuumNode`. | +| `Unsupported class file major version` or `invalid source release: 21` | The build runs on the wrong JDK. Run `java -version` and `./gradlew --version`; both must report 21. Set `JAVA_HOME` to a JDK 21 and stop old daemons with `./gradlew --stop`. | +| `Java heap space`, `GC overhead limit exceeded` or the Gradle daemon dies during compilation | Gradle needs more memory. The template sets `org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g` in `gradle.properties`. Keep that line; if you removed it, put it back, and make sure the machine has the memory to spare. | | `Port 8080 was already in use` on `bootRun` | The local API server uses 8080. Keep `server.port: ${SERVER_PORT:8090}` in `application.yaml`. | +| Worker starts but logs connection errors for Kafka, Temporal or MinIO | The local stack isn't running or isn't healthy. Run `docker compose ps` in `docker/` and wait until every container is healthy. The stack needs about 8 GB of RAM, so raise Docker Desktop's memory limit if containers keep restarting or get killed. | +| Worker starts but registers `[]` for both process and trigger nodes | The worker didn't load your module. See the [checklist above](#my-node-doesnt-show-up-in-the-workbench), steps 3 to 5. | +| `NoSuchBeanDefinitionException` or `UnsatisfiedDependencyException` for your node at start-up | The node's constructor asks for a bean Spring can't provide. Nodes can take `ObjectMapper`; anything else must be a bean from the worker. If in doubt, make the constructor empty. | | A node fails at random, or runs on the wrong worker | Several workers share a task queue. Temporal gives work to whichever worker polls first, including one that doesn't have the node, and nothing warns you. Set a unique `node-task-queue` in `application.yaml` and `taskQueue` in the chart. | | `IllegalArgumentException: Unsupported type` while writing | A cell value isn't a supported type (String, Int, Long, Float, Double, Boolean, List, Map or SVG). Convert it, or leave the key out instead of using `null`. See [Reading and writing rows](./step-4-write-your-node.md#reading-and-writing-rows). | -| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `org.example.node.MyNodeModel` it is `src/main/resources/org/example/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | +| `CredentialsNotFoundException` | The credential name in the node's settings doesn't exist on the credentials server. In the local stack there is no credentials server at all; see [Use a credential](./recipes.md#use-a-credential). | +| Help page reads "Documentation not found" | The `.doc.md` path doesn't match the node's full package and class name. For `com.acme.demo.node.MyNodeModel` it is `src/main/resources/com/acme/demo/node/MyNodeModel.doc.md`. See [Step 4](./step-4-write-your-node.md#2-the-help-page). | + +## Release and deployment errors + +| Symptom | Cause and fix | +|---------|---------------| | Helm: `template: no template associated with name` | A rename in `charts/` was only partly done. Every `include "…"` must match a `define` in `_helpers.tpl`. See [Step 3](./step-3-make-it-yours.md#5-the-helm-chart). | | PR fails `validate-versions` | Bump `featureVersion` in `gradle.properties` and set the chart's `appVersion` to the same value. See [Step 6](./step-6-ship-it.md#1-bump-the-version). | +| Release workflow doesn't start | `on-release.yml` and `release.yml` run on a **published GitHub Release**, not on a tag or a merge. See [Step 6](./step-6-ship-it.md#the-release-flow). | +| Maven Central deploy fails with a namespace or signing error | The `group` (your package) isn't a namespace you verified in the Central Portal, or the GPG secrets are missing. Verify the namespace, or switch publishing off; see [Step 6](./step-6-ship-it.md#3-add-repository-secrets). | +| Jib push fails with `401 Unauthorized` or `denied` | `DOCKER_HUB_USERNAME` / `DOCKER_HUB_PASSWORD` are missing or wrong, or the account can't push to the repository named in `jibToImage`. See [Step 6](./step-6-ship-it.md#4-where-the-image-goes). | +| Pod stuck in `ImagePullBackOff` | The image name or tag in the chart doesn't exist, or the registry is private and the pod has no pull secret. See [Step 6](./step-6-ship-it.md#4-where-the-image-goes). | +| Pod stuck in `Init` | An init container is waiting for Kafka, Temporal or the API server. Its address in `continuum.infra.*` or `continuum.apiServer` doesn't match a real service. Check with `kubectl get svc -n continuum` and see [Step 6](./step-6-ship-it.md#5-configure-the-chart). | +| Pod fails to start because a Secret is missing | `continuum.secrets.existingMinioSecret` names a Secret that doesn't exist in the namespace. See [Step 6](./step-6-ship-it.md#5-configure-the-chart). | | Saved workflows break after a rename | You renamed or moved a node class. The full class name is the node's identity in saved workflows, so don't rename classes after shipping. | - diff --git a/versioned_docs/version-0.0.20/contributing/feature-template.md b/versioned_docs/version-0.0.20/contributing/feature-template.md index 244b8db..a379f9f 100644 --- a/versioned_docs/version-0.0.20/contributing/feature-template.md +++ b/versioned_docs/version-0.0.20/contributing/feature-template.md @@ -11,7 +11,7 @@ Continuum is designed to be extended by **adding new workers**, not modifying ex To build your own set of nodes, start from [`continuum-feature-template`](https://github.com/projectcontinuum-org/continuum-feature-template) — a scaffold for a standalone Gradle project with the Spring Boot worker setup, Temporal registration, and `@ContinuumNode` conventions already wired up. :::tip -The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it and writing your first node, see [Create New Nodes](./create-new-nodes/overview.md). +The template builds against platform `0.0.20` out of the box and includes a Kotlin and a Java example node, CI/CD workflows, a Helm chart and a local Docker stack. For a step-by-step walkthrough of cloning it, renaming it, writing your first node (in Kotlin or Java) and shipping it, see [Create New Nodes](./create-new-nodes/overview.md). ::: Once your worker is running and registering nodes, it can be deployed as an independent release into the same Kubernetes namespace as the core platform (see [Deployment](../deployment/helm-charts.md)) — no changes to `continuum-platform-core` or any other feature repo required. From 72033b8d324df51b4adc54003129a255a63c7516 Mon Sep 17 00:00:00 2001 From: projectcontinuum Date: Thu, 29 Oct 2026 19:20:51 +0530 Subject: [PATCH 6/6] CONTNM-137: add more colors --- docs/architecture/data-format.md | 8 ++- docs/architecture/node-model.md | 18 +++--- docs/architecture/overview.md | 63 +++++++++++-------- .../contributing/create-new-nodes/overview.md | 19 +++++- .../step-2-tour-the-template.md | 27 +++++++- .../create-new-nodes/step-6-ship-it.md | 45 +++++++++---- docs/getting-started/local-setup.md | 36 ++++++----- docs/intro.mdx | 19 +++--- .../architecture/data-format.md | 8 ++- .../version-0.0.20/architecture/node-model.md | 18 +++--- .../version-0.0.20/architecture/overview.md | 63 +++++++++++-------- .../contributing/create-new-nodes/overview.md | 19 +++++- .../step-2-tour-the-template.md | 27 +++++++- .../create-new-nodes/step-6-ship-it.md | 45 +++++++++---- .../getting-started/local-setup.md | 36 ++++++----- versioned_docs/version-0.0.20/intro.mdx | 19 +++--- 16 files changed, 326 insertions(+), 144 deletions(-) diff --git a/docs/architecture/data-format.md b/docs/architecture/data-format.md index e08e086..bc3ccc1 100644 --- a/docs/architecture/data-format.md +++ b/docs/architecture/data-format.md @@ -19,11 +19,15 @@ All data passed between workflow nodes is **Apache Parquet** (Snappy-compressed, ```mermaid flowchart LR - A["🧩 Node A
NodeOutputWriter"] -->|"output.{portId}.parquet"| S3[("🗄️ MinIO (S3)")] - S3 -->|"input.{portId}.parquet"| B["🧩 Node B
NodeInputReader"] + A[/"🧩 Node A
NodeOutputWriter"/] ==>|"write
output.{portId}.parquet"| S3[("🗄️ MinIO (S3)
one Parquet file
per port")] + S3 ==>|"read
input.{portId}.parquet"| B[\"🧩 Node B
NodeInputReader"\] + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class A,B worker class S3 store ``` diff --git a/docs/architecture/node-model.md b/docs/architecture/node-model.md index bd47aa6..18d2235 100644 --- a/docs/architecture/node-model.md +++ b/docs/architecture/node-model.md @@ -45,21 +45,25 @@ At startup, each worker publishes its available nodes to Kafka so the platform c ```mermaid flowchart LR - W["🧩 Worker (startup)
discovers all @ContinuumNode
beans via Spring"] - K["📨 Kafka topic
FeatureRegistration
(Avro binary)"] - B["🔁 Message Bridge
consumes & upserts
per node"] - DB[("🐘 PostgreSQL
registered_nodes
nodeId + taskQueue")] + W[/"🧩 Worker starts
finds every @ContinuumNode
bean via Spring"/] + K[["📨 Kafka topic
FeatureRegistration
Avro binary"]] + B["🔁 Message Bridge
consumes and upserts
one row per node"] + DB[("🐘 PostgreSQL
registered_nodes
nodeId + taskQueue")] + UI(["🖥️ Workbench palette
your node appears"]) - W -->|publish| K --> B -->|upsert| DB + W ==>|"publish"| K ==> B ==>|"upsert"| DB -.->|"served via API"| UI - classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px - classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class W worker class K stream class B core class DB store + class UI ui ``` diff --git a/docs/architecture/overview.md b/docs/architecture/overview.md index b743d12..add3bd5 100644 --- a/docs/architecture/overview.md +++ b/docs/architecture/overview.md @@ -9,37 +9,38 @@ Continuum is split into a browser frontend, a core backend (API server + Tempora ```mermaid flowchart TB - subgraph Browser["🖥️ Browser — Continuum Workbench"] - UI["Eclipse Theia IDE + React Flow canvas"] + subgraph Browser["🖥️ Browser: Continuum Workbench"] + UI(["🎨 Eclipse Theia IDE + React Flow canvas"]) end - API["🌐 API Server"] - Bridge["🔁 Message Bridge
Kafka → MQTT"] - Temporal["⏱️ Temporal
orchestration"] - Kafka["📨 Kafka"] + API["🌐 API Server"] + Temporal{{"⏱️ Temporal
orchestration"}} + Bridge["🔁 Message Bridge
Kafka → MQTT"] + Kafka[["📨 Kafka
events"]] - subgraph Workers["🧩 Feature Workers"] + subgraph Workers["🧩 Feature Workers: add yours here"] direction LR Base["📊 Base"] Chem["🧪 Cheminformatics"] AI["🤖 AI / ML"] end - MinIO[("🗄️ MinIO (S3)
Parquet files")] + MinIO[("🗄️ MinIO (S3)
Parquet files")] - UI -->|REST| API - Bridge -->|MQTT / WebSocket| UI - API --> Temporal - Temporal -->|dispatches| Workers - Workers -->|events| Kafka - Kafka --> Bridge - Workers <-->|read / write| MinIO + UI ==>|"REST"| API + Bridge -.->|"MQTT / WebSocket
live status"| UI + API ==> Temporal + Temporal ==>|"dispatches"| Workers + Workers -.->|"events"| Kafka + Kafka -.-> Bridge + Workers <-->|"read / write"| MinIO classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class UI ui class API,Temporal core class Kafka,Bridge stream @@ -74,17 +75,29 @@ sequenceDiagram participant S as 🗄️ MinIO participant K as 📨 Kafka → MQTT - B->>A: Execute workflow (REST) - A->>T: Start ContinuumWorkflow - T->>A: InitializeActivity: resolve task queues - loop each unblocked DAG node - T->>W: IContinuumNodeActivity.run() - W->>S: Read input Parquet - W->>S: Write output Parquet - W-->>T: Progress signals - T-->>K: WorkflowUpdateEvent - K-->>B: Node status (MQTT over WebSocket) + rect rgba(139, 92, 246, 0.10) + Note over B,T: 🚀 Start + B->>+A: Execute workflow (REST) + A->>+T: Start ContinuumWorkflow + T->>A: InitializeActivity: resolve task queues + deactivate A end + + loop 🔁 each unblocked DAG node + rect rgba(6, 182, 212, 0.10) + Note over T,S: ⚙️ Run the node + T->>+W: IContinuumNodeActivity.run() + W->>S: Read input Parquet + W->>S: Write output Parquet + W-->>-T: Progress signals + end + rect rgba(245, 158, 11, 0.12) + Note over T,B: 📡 Live status + T-->>K: WorkflowUpdateEvent + K-->>B: Node status (MQTT over WebSocket) + end + end + deactivate T ``` ## Why this survives crashes diff --git a/docs/contributing/create-new-nodes/overview.md b/docs/contributing/create-new-nodes/overview.md index f197fff..a0018a1 100644 --- a/docs/contributing/create-new-nodes/overview.md +++ b/docs/contributing/create-new-nodes/overview.md @@ -26,8 +26,23 @@ A **node** is a block on the Workbench canvas that reads tables, does something You don't build a worker from scratch. The template is already a complete, working worker with two example nodes (one Kotlin, one Java), a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. ```mermaid -flowchart LR - S1["1
Clone and run"] --> S2["2
Tour"] --> S3["3
Rename"] --> S4["4
Write your node"] --> S5["5
Test and run"] --> S6["6
Ship"] +flowchart TB + S1(["🧲 1 · Clone and run
see it work first"]) --> S2(["🔭 2 · Tour
what to touch"]) + S2 --> S3(["🏷️ 3 · Rename
make it yours"]) + S3 --> S4(["✍️ 4 · Write
class, help, test"]) + S4 --> S5(["🧪 5 · Test and run
see it in the Workbench"]) + S5 --> S6(["🚢 6 · Ship
release and Helm"]) + S6 ==> Done(["🎉 Your nodes are live"]) + + classDef setup fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef build fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef ship fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef done fill:#10b98133,stroke:#10b981,stroke-width:3px + class S1,S2 setup + class S3,S4 build + class S5,S6 ship + class Done done + linkStyle 5 stroke:#10b981,stroke-width:4px ``` ## What you need diff --git a/docs/contributing/create-new-nodes/step-2-tour-the-template.md b/docs/contributing/create-new-nodes/step-2-tour-the-template.md index 23ee2c9..2d60cf0 100644 --- a/docs/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/docs/contributing/create-new-nodes/step-2-tour-the-template.md @@ -19,9 +19,30 @@ Your repository builds **one worker**. The worker is a small Spring Boot app tha ```mermaid flowchart LR - W["worker/
The app you run and deploy.
No node logic."] - W -->|loads| K["features/continuum-feature-hello
Nodes in Kotlin"] - W -->|loads| J["features/continuum-feature-hello-java
Nodes in Java"] + subgraph Repo["📦 Your repository"] + W["🚀 worker/
Spring Boot app you run and deploy
no node logic"] + K["🟣 features/continuum-feature-hello
nodes in Kotlin"] + J["☕ features/continuum-feature-hello-java
nodes in Java"] + W -->|loads| K + W -->|loads| J + end + + API["🌐 API Server
platform"] + WB["🖥️ Workbench
node palette"] + T["⏱️ Temporal
your task queue"] + + W ==>|"① announces every @ContinuumNode"| API + API -->|"② nodes appear"| WB + T ==>|"③ sends work to"| W + + classDef code fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef entry fill:#8b5cf633,stroke:#8b5cf6,stroke-width:3px + classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef ui fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + class K,J code + class W entry + class API,T core + class WB ui ``` At startup the worker finds every class annotated with `@ContinuumNode`, listens on its own Temporal task queue for work, and announces each node to the platform so it shows up in the Workbench palette. diff --git a/docs/contributing/create-new-nodes/step-6-ship-it.md b/docs/contributing/create-new-nodes/step-6-ship-it.md index 7b8bdbc..a951541 100644 --- a/docs/contributing/create-new-nodes/step-6-ship-it.md +++ b/docs/contributing/create-new-nodes/step-6-ship-it.md @@ -17,17 +17,40 @@ Shipping is mostly already set up in the template. This page explains what each ```mermaid flowchart TB - A["Bump featureVersion in gradle.properties
Update appVersion in Chart.yaml
(must match)"] --> B["Open PR: CI checks run"] - B --> C{Pass CI?} - C -->|No| D["Fix and push again"] - D --> B - C -->|Yes| E["Merge to main"] - E --> F["Go to GitHub Releases page"] - F --> G["Click 'Create a new release'"] - G --> H["GitHub release triggers workflows"] - H --> I["Feature modules to Maven Central"] - H --> J["Worker image to Docker Hub"] - H --> K["Helm chart attached to the release
and added to the gh-pages index"] + A(["✏️ Bump versions
featureVersion in gradle.properties
appVersion in Chart.yaml (must match)"]) + B["🔀 Open a pull request
CI runs build, versions, chart lint"] + C{"✅ CI green?"} + D["🔧 Fix and push again"] + E["🌿 Merge to main"] + F(["📣 Publish a GitHub Release
Releases → Create a new release"]) + I[("📚 Maven Central
feature libraries")] + J[("🐳 Docker Hub
worker image")] + K[("📦 Helm chart
release asset + gh-pages index")] + L(["☸️ helm install / upgrade
nodes appear in the Workbench"]) + + A --> B --> C + C -->|"no"| D --> B + C -->|"yes"| E --> F + F ==>|"on-release.yml"| I + F ==>|"on-release.yml"| J + F ==>|"release.yml"| K + I ~~~ L + J ==> L + K ==> L + + classDef dev fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef ci fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef fail fill:#ef444433,stroke:#ef4444,stroke-width:2px + classDef release fill:#ec489933,stroke:#ec4899,stroke-width:3px + classDef out fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef done fill:#10b98133,stroke:#10b981,stroke-width:3px + class A,E dev + class B,C ci + class D fail + class F release + class I,J,K out + class L done + linkStyle 2,3 stroke:#ef4444,stroke-width:2px,stroke-dasharray:5 4 ``` :::warning[Publish a GitHub Release] diff --git a/docs/getting-started/local-setup.md b/docs/getting-started/local-setup.md index 4f86992..c73fbb4 100644 --- a/docs/getting-started/local-setup.md +++ b/docs/getting-started/local-setup.md @@ -64,31 +64,37 @@ The compose stack has three layers: infrastructure, platform services, and featu ```mermaid flowchart LR - subgraph Workers["🧩 Feature workers"] - FB["continuum-feature-base"] - FC["continuum-feature-cheminformatics"] + subgraph Workers["🧩 Feature workers: yours join here"] + FB["📊 continuum-feature-base"] + FC["🧪 continuum-feature-cheminformatics"] end subgraph Platform["🌐 Platform services"] - WB["continuum-workbench"] + WB(["🖥️ continuum-workbench"]) API["continuum-api-server"] - MB["continuum-message-bridge"] + MB["🔁 continuum-message-bridge"] end subgraph Infra["🏗️ Infrastructure"] - PG[("PostgreSQL")] - T["Temporal"] - K["Kafka + Schema Registry"] - MQ["Mosquitto"] - S3[("MinIO")] + PG[("🐘 PostgreSQL")] + T{{"⏱️ Temporal"}} + K[["📨 Kafka + Schema Registry"]] + MQ[["📡 Mosquitto"]] + S3[("🗄️ MinIO")] end - Workers --> Platform --> Infra - Workers --> Infra + Workers ==> Platform ==> Infra + Workers -.-> Infra - classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class FB,FC worker - class WB,API,MB core - class PG,T,K,MQ,S3 store + class WB ui + class API,MB core + class PG,S3 store + class T core + class K,MQ stream ``` ### Infrastructure services diff --git a/docs/intro.mdx b/docs/intro.mdx index bf039a8..1332f4c 100644 --- a/docs/intro.mdx +++ b/docs/intro.mdx @@ -50,19 +50,24 @@ A workflow is a directed graph of nodes. Each node runs as a Temporal activity d ```mermaid flowchart LR - UI["🖥️ Workbench
(browser)"] -->|Execute| API["API Server"] - API --> T["⏱️ Temporal"] - T -->|dispatch node| W1["📊 Base Analytics"] - T -->|dispatch node| W2["🧪 Cheminformatics"] - T -->|dispatch node| W3["🤖 AI / ML"] - T -->|dispatch node| W4["🧩 Your worker"] + UI(["🖥️ Workbench
draw a workflow
in your browser"]) ==>|"▶ Execute"| API["🌐 API Server"] + API ==> T{{"⏱️ Temporal
durable orchestration
survives crashes"}} + T -->|"dispatch node"| W1["📊 Base Analytics"] + T -->|"dispatch node"| W2["🧪 Cheminformatics"] + T -->|"dispatch node"| W3["🤖 AI / ML"] + T -.->|"dispatch node"| W4["🧩 Your worker
+ your nodes"] classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class UI ui class API,T core - class W1,W2,W3,W4 worker + class W1,W2,W3 worker + class W4 hero + linkStyle 1 stroke:#ec4899,stroke-width:4px ``` See [Architecture Overview](./architecture/overview.md) for the full execution path. diff --git a/versioned_docs/version-0.0.20/architecture/data-format.md b/versioned_docs/version-0.0.20/architecture/data-format.md index e08e086..bc3ccc1 100644 --- a/versioned_docs/version-0.0.20/architecture/data-format.md +++ b/versioned_docs/version-0.0.20/architecture/data-format.md @@ -19,11 +19,15 @@ All data passed between workflow nodes is **Apache Parquet** (Snappy-compressed, ```mermaid flowchart LR - A["🧩 Node A
NodeOutputWriter"] -->|"output.{portId}.parquet"| S3[("🗄️ MinIO (S3)")] - S3 -->|"input.{portId}.parquet"| B["🧩 Node B
NodeInputReader"] + A[/"🧩 Node A
NodeOutputWriter"/] ==>|"write
output.{portId}.parquet"| S3[("🗄️ MinIO (S3)
one Parquet file
per port")] + S3 ==>|"read
input.{portId}.parquet"| B[\"🧩 Node B
NodeInputReader"\] + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class A,B worker class S3 store ``` diff --git a/versioned_docs/version-0.0.20/architecture/node-model.md b/versioned_docs/version-0.0.20/architecture/node-model.md index bd47aa6..18d2235 100644 --- a/versioned_docs/version-0.0.20/architecture/node-model.md +++ b/versioned_docs/version-0.0.20/architecture/node-model.md @@ -45,21 +45,25 @@ At startup, each worker publishes its available nodes to Kafka so the platform c ```mermaid flowchart LR - W["🧩 Worker (startup)
discovers all @ContinuumNode
beans via Spring"] - K["📨 Kafka topic
FeatureRegistration
(Avro binary)"] - B["🔁 Message Bridge
consumes & upserts
per node"] - DB[("🐘 PostgreSQL
registered_nodes
nodeId + taskQueue")] + W[/"🧩 Worker starts
finds every @ContinuumNode
bean via Spring"/] + K[["📨 Kafka topic
FeatureRegistration
Avro binary"]] + B["🔁 Message Bridge
consumes and upserts
one row per node"] + DB[("🐘 PostgreSQL
registered_nodes
nodeId + taskQueue")] + UI(["🖥️ Workbench palette
your node appears"]) - W -->|publish| K --> B -->|upsert| DB + W ==>|"publish"| K ==> B ==>|"upsert"| DB -.->|"served via API"| UI - classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px - classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class W worker class K stream class B core class DB store + class UI ui ``` diff --git a/versioned_docs/version-0.0.20/architecture/overview.md b/versioned_docs/version-0.0.20/architecture/overview.md index b743d12..add3bd5 100644 --- a/versioned_docs/version-0.0.20/architecture/overview.md +++ b/versioned_docs/version-0.0.20/architecture/overview.md @@ -9,37 +9,38 @@ Continuum is split into a browser frontend, a core backend (API server + Tempora ```mermaid flowchart TB - subgraph Browser["🖥️ Browser — Continuum Workbench"] - UI["Eclipse Theia IDE + React Flow canvas"] + subgraph Browser["🖥️ Browser: Continuum Workbench"] + UI(["🎨 Eclipse Theia IDE + React Flow canvas"]) end - API["🌐 API Server"] - Bridge["🔁 Message Bridge
Kafka → MQTT"] - Temporal["⏱️ Temporal
orchestration"] - Kafka["📨 Kafka"] + API["🌐 API Server"] + Temporal{{"⏱️ Temporal
orchestration"}} + Bridge["🔁 Message Bridge
Kafka → MQTT"] + Kafka[["📨 Kafka
events"]] - subgraph Workers["🧩 Feature Workers"] + subgraph Workers["🧩 Feature Workers: add yours here"] direction LR Base["📊 Base"] Chem["🧪 Cheminformatics"] AI["🤖 AI / ML"] end - MinIO[("🗄️ MinIO (S3)
Parquet files")] + MinIO[("🗄️ MinIO (S3)
Parquet files")] - UI -->|REST| API - Bridge -->|MQTT / WebSocket| UI - API --> Temporal - Temporal -->|dispatches| Workers - Workers -->|events| Kafka - Kafka --> Bridge - Workers <-->|read / write| MinIO + UI ==>|"REST"| API + Bridge -.->|"MQTT / WebSocket
live status"| UI + API ==> Temporal + Temporal ==>|"dispatches"| Workers + Workers -.->|"events"| Kafka + Kafka -.-> Bridge + Workers <-->|"read / write"| MinIO classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class UI ui class API,Temporal core class Kafka,Bridge stream @@ -74,17 +75,29 @@ sequenceDiagram participant S as 🗄️ MinIO participant K as 📨 Kafka → MQTT - B->>A: Execute workflow (REST) - A->>T: Start ContinuumWorkflow - T->>A: InitializeActivity: resolve task queues - loop each unblocked DAG node - T->>W: IContinuumNodeActivity.run() - W->>S: Read input Parquet - W->>S: Write output Parquet - W-->>T: Progress signals - T-->>K: WorkflowUpdateEvent - K-->>B: Node status (MQTT over WebSocket) + rect rgba(139, 92, 246, 0.10) + Note over B,T: 🚀 Start + B->>+A: Execute workflow (REST) + A->>+T: Start ContinuumWorkflow + T->>A: InitializeActivity: resolve task queues + deactivate A end + + loop 🔁 each unblocked DAG node + rect rgba(6, 182, 212, 0.10) + Note over T,S: ⚙️ Run the node + T->>+W: IContinuumNodeActivity.run() + W->>S: Read input Parquet + W->>S: Write output Parquet + W-->>-T: Progress signals + end + rect rgba(245, 158, 11, 0.12) + Note over T,B: 📡 Live status + T-->>K: WorkflowUpdateEvent + K-->>B: Node status (MQTT over WebSocket) + end + end + deactivate T ``` ## Why this survives crashes diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md index f197fff..a0018a1 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/overview.md @@ -26,8 +26,23 @@ A **node** is a block on the Workbench canvas that reads tables, does something You don't build a worker from scratch. The template is already a complete, working worker with two example nodes (one Kotlin, one Java), a build, tests, CI/CD, a Helm chart and a local stack. Your job is to rename it and swap in your own nodes. ```mermaid -flowchart LR - S1["1
Clone and run"] --> S2["2
Tour"] --> S3["3
Rename"] --> S4["4
Write your node"] --> S5["5
Test and run"] --> S6["6
Ship"] +flowchart TB + S1(["🧲 1 · Clone and run
see it work first"]) --> S2(["🔭 2 · Tour
what to touch"]) + S2 --> S3(["🏷️ 3 · Rename
make it yours"]) + S3 --> S4(["✍️ 4 · Write
class, help, test"]) + S4 --> S5(["🧪 5 · Test and run
see it in the Workbench"]) + S5 --> S6(["🚢 6 · Ship
release and Helm"]) + S6 ==> Done(["🎉 Your nodes are live"]) + + classDef setup fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef build fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef ship fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef done fill:#10b98133,stroke:#10b981,stroke-width:3px + class S1,S2 setup + class S3,S4 build + class S5,S6 ship + class Done done + linkStyle 5 stroke:#10b981,stroke-width:4px ``` ## What you need diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md index 23ee2c9..2d60cf0 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-2-tour-the-template.md @@ -19,9 +19,30 @@ Your repository builds **one worker**. The worker is a small Spring Boot app tha ```mermaid flowchart LR - W["worker/
The app you run and deploy.
No node logic."] - W -->|loads| K["features/continuum-feature-hello
Nodes in Kotlin"] - W -->|loads| J["features/continuum-feature-hello-java
Nodes in Java"] + subgraph Repo["📦 Your repository"] + W["🚀 worker/
Spring Boot app you run and deploy
no node logic"] + K["🟣 features/continuum-feature-hello
nodes in Kotlin"] + J["☕ features/continuum-feature-hello-java
nodes in Java"] + W -->|loads| K + W -->|loads| J + end + + API["🌐 API Server
platform"] + WB["🖥️ Workbench
node palette"] + T["⏱️ Temporal
your task queue"] + + W ==>|"① announces every @ContinuumNode"| API + API -->|"② nodes appear"| WB + T ==>|"③ sends work to"| W + + classDef code fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef entry fill:#8b5cf633,stroke:#8b5cf6,stroke-width:3px + classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef ui fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + class K,J code + class W entry + class API,T core + class WB ui ``` At startup the worker finds every class annotated with `@ContinuumNode`, listens on its own Temporal task queue for work, and announces each node to the platform so it shows up in the Workbench palette. diff --git a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md index 7b8bdbc..a951541 100644 --- a/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md +++ b/versioned_docs/version-0.0.20/contributing/create-new-nodes/step-6-ship-it.md @@ -17,17 +17,40 @@ Shipping is mostly already set up in the template. This page explains what each ```mermaid flowchart TB - A["Bump featureVersion in gradle.properties
Update appVersion in Chart.yaml
(must match)"] --> B["Open PR: CI checks run"] - B --> C{Pass CI?} - C -->|No| D["Fix and push again"] - D --> B - C -->|Yes| E["Merge to main"] - E --> F["Go to GitHub Releases page"] - F --> G["Click 'Create a new release'"] - G --> H["GitHub release triggers workflows"] - H --> I["Feature modules to Maven Central"] - H --> J["Worker image to Docker Hub"] - H --> K["Helm chart attached to the release
and added to the gh-pages index"] + A(["✏️ Bump versions
featureVersion in gradle.properties
appVersion in Chart.yaml (must match)"]) + B["🔀 Open a pull request
CI runs build, versions, chart lint"] + C{"✅ CI green?"} + D["🔧 Fix and push again"] + E["🌿 Merge to main"] + F(["📣 Publish a GitHub Release
Releases → Create a new release"]) + I[("📚 Maven Central
feature libraries")] + J[("🐳 Docker Hub
worker image")] + K[("📦 Helm chart
release asset + gh-pages index")] + L(["☸️ helm install / upgrade
nodes appear in the Workbench"]) + + A --> B --> C + C -->|"no"| D --> B + C -->|"yes"| E --> F + F ==>|"on-release.yml"| I + F ==>|"on-release.yml"| J + F ==>|"release.yml"| K + I ~~~ L + J ==> L + K ==> L + + classDef dev fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px + classDef ci fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef fail fill:#ef444433,stroke:#ef4444,stroke-width:2px + classDef release fill:#ec489933,stroke:#ec4899,stroke-width:3px + classDef out fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef done fill:#10b98133,stroke:#10b981,stroke-width:3px + class A,E dev + class B,C ci + class D fail + class F release + class I,J,K out + class L done + linkStyle 2,3 stroke:#ef4444,stroke-width:2px,stroke-dasharray:5 4 ``` :::warning[Publish a GitHub Release] diff --git a/versioned_docs/version-0.0.20/getting-started/local-setup.md b/versioned_docs/version-0.0.20/getting-started/local-setup.md index 4f86992..c73fbb4 100644 --- a/versioned_docs/version-0.0.20/getting-started/local-setup.md +++ b/versioned_docs/version-0.0.20/getting-started/local-setup.md @@ -64,31 +64,37 @@ The compose stack has three layers: infrastructure, platform services, and featu ```mermaid flowchart LR - subgraph Workers["🧩 Feature workers"] - FB["continuum-feature-base"] - FC["continuum-feature-cheminformatics"] + subgraph Workers["🧩 Feature workers: yours join here"] + FB["📊 continuum-feature-base"] + FC["🧪 continuum-feature-cheminformatics"] end subgraph Platform["🌐 Platform services"] - WB["continuum-workbench"] + WB(["🖥️ continuum-workbench"]) API["continuum-api-server"] - MB["continuum-message-bridge"] + MB["🔁 continuum-message-bridge"] end subgraph Infra["🏗️ Infrastructure"] - PG[("PostgreSQL")] - T["Temporal"] - K["Kafka + Schema Registry"] - MQ["Mosquitto"] - S3[("MinIO")] + PG[("🐘 PostgreSQL")] + T{{"⏱️ Temporal"}} + K[["📨 Kafka + Schema Registry"]] + MQ[["📡 Mosquitto"]] + S3[("🗄️ MinIO")] end - Workers --> Platform --> Infra - Workers --> Infra + Workers ==> Platform ==> Infra + Workers -.-> Infra - classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px + classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class FB,FC worker - class WB,API,MB core - class PG,T,K,MQ,S3 store + class WB ui + class API,MB core + class PG,S3 store + class T core + class K,MQ stream ``` ### Infrastructure services diff --git a/versioned_docs/version-0.0.20/intro.mdx b/versioned_docs/version-0.0.20/intro.mdx index bf039a8..1332f4c 100644 --- a/versioned_docs/version-0.0.20/intro.mdx +++ b/versioned_docs/version-0.0.20/intro.mdx @@ -50,19 +50,24 @@ A workflow is a directed graph of nodes. Each node runs as a Temporal activity d ```mermaid flowchart LR - UI["🖥️ Workbench
(browser)"] -->|Execute| API["API Server"] - API --> T["⏱️ Temporal"] - T -->|dispatch node| W1["📊 Base Analytics"] - T -->|dispatch node| W2["🧪 Cheminformatics"] - T -->|dispatch node| W3["🤖 AI / ML"] - T -->|dispatch node| W4["🧩 Your worker"] + UI(["🖥️ Workbench
draw a workflow
in your browser"]) ==>|"▶ Execute"| API["🌐 API Server"] + API ==> T{{"⏱️ Temporal
durable orchestration
survives crashes"}} + T -->|"dispatch node"| W1["📊 Base Analytics"] + T -->|"dispatch node"| W2["🧪 Cheminformatics"] + T -->|"dispatch node"| W3["🤖 AI / ML"] + T -.->|"dispatch node"| W4["🧩 Your worker
+ your nodes"] classDef ui fill:#8b5cf633,stroke:#8b5cf6,stroke-width:2px classDef core fill:#ec489933,stroke:#ec4899,stroke-width:2px + classDef stream fill:#f59e0b33,stroke:#f59e0b,stroke-width:2px classDef worker fill:#06b6d433,stroke:#06b6d4,stroke-width:2px + classDef store fill:#10b98133,stroke:#10b981,stroke-width:2px + classDef hero fill:#06b6d433,stroke:#06b6d4,stroke-width:4px,stroke-dasharray:6 3 class UI ui class API,T core - class W1,W2,W3,W4 worker + class W1,W2,W3 worker + class W4 hero + linkStyle 1 stroke:#ec4899,stroke-width:4px ``` See [Architecture Overview](./architecture/overview.md) for the full execution path.