-
Notifications
You must be signed in to change notification settings - Fork 1
feat(workers): add Temporal worker structure and initial implementation #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
28d0c25
feat(workers): add Temporal worker structure and initial implementation
anatolyshipitz 1911fba
chore(workers): remove outdated README and clean up code
anatolyshipitz 5991f4f
feat(docker): update Temporal service configuration and add worker
anatolyshipitz 49c15b9
fix(workflows): add missing newline at end of file in index.ts
anatolyshipitz 8c1d0be
fix: add missing newlines at the end of multiple TypeScript files
anatolyshipitz 91c7c23
fix: add missing newline at end of tsconfig.json
anatolyshipitz 605b01c
refactor(package): rename worker and update paths in package.json
anatolyshipitz a278a28
Update dependencies and rename package in package-lock.json
anatolyshipitz 4fd8b8a
docs: update project structure and shared utilities documentation
anatolyshipitz 5c402e9
feat(docker): add temporal-worker-main service and update configurations
anatolyshipitz 29f3c88
refactor(index.ts): filter out test files from activity modules
anatolyshipitz 16ced12
fix(docker): pin netcat-openbsd version in Dockerfile.temporal
anatolyshipitz 270ecfd
refactor(index.ts): enhance activity module import logic
anatolyshipitz fa344d1
fix(docker): remove version pin for netcat-openbsd in Dockerfile.temp…
anatolyshipitz 33c06b1
refactor(index.ts): streamline activity module loading
anatolyshipitz 6edcf5a
fix(docker): pin netcat-openbsd version in Dockerfile.temporal
anatolyshipitz 9bbfd7c
fix(docker): update Dockerfile.temporal-worker-main for build process
anatolyshipitz 1e45e6f
fix(docker): update Docker configurations and ignore files
anatolyshipitz ef99fc3
feat(tests): add Vitest configuration and initial test cases
anatolyshipitz 351d681
feat(coverage): enhance SonarQube integration and testing setup
anatolyshipitz 07d188d
feat(dependencies): update package-lock and package.json for improved…
anatolyshipitz 7f710e7
feat(sonar): add exclusions to sonar-project.properties for improved …
anatolyshipitz 95467f6
Merge branch 'main' into feature/64211-temporal-worker
anatolyshipitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| description: | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
| # Temporal Project Structure Rule | ||
|
|
||
| ## Purpose | ||
| Defines the required directory and documentation structure for Temporal-based workflows and workers in this repository. | ||
|
|
||
| ## Project Structure | ||
|
|
||
| The project follows a modular structure with workers as independent packages: | ||
|
|
||
| ``` | ||
| . | ||
| ├── workers/ # Root directory for all Temporal workers | ||
| │ ├── main/ # Main worker package | ||
| │ │ ├── src/ # Source code | ||
| │ │ │ ├── activities/ # Activity implementations | ||
| │ │ │ ├── workflows/ # Workflow definitions | ||
| │ │ │ ├── index.ts # Worker entry point | ||
| │ │ │ └── types.ts # Worker-specific types | ||
| │ │ ├── package.json # Worker dependencies | ||
| │ │ ├── tsconfig.json # TypeScript configuration | ||
| │ │ └── README.md # Worker documentation | ||
| │ └── [other-workers]/ # Additional worker packages | ||
| ├── docs/ # Project documentation | ||
| │ └── user-guide/ # User guides and documentation | ||
| ├── docker-compose.yml # Docker compose configuration | ||
| └── Dockerfile.temporal # Base Temporal worker Dockerfile | ||
| ``` | ||
|
|
||
| All Temporal workers must be placed under `src/workers/<worker-name>/` and include: | ||
|
|
||
| - `workflows/` — workflow definitions for this worker | ||
| - `activities/` — activity implementations for this worker | ||
| - `index.ts` — worker entry point (registers workflows/activities, sets task queue) | ||
| - `types.ts` — (optional) worker-specific types | ||
| - `README.md` — brief usage and development instructions | ||
|
|
||
| Shared utilities, types, and configuration should be placed in `src/shared/`. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## Documentation | ||
|
|
||
| Each worker must have a dedicated documentation file at: | ||
| `docs/user-guide/temporal/workers/<worker-name>.md` | ||
|
|
||
| Documentation must include: | ||
|
|
||
| - Purpose and responsibilities of the worker | ||
| - List and description of workflows and activities | ||
| - Required environment variables | ||
| - Integration points (e.g., databases, APIs) | ||
| - Best practices and troubleshooting | ||
|
|
||
| ## Best Practices | ||
|
|
||
| - Keep workflow and activity logic modular and well-tested. | ||
| - Use clear, descriptive names for workflows, activities, and task queues. | ||
| - Update documentation with every significant change to workflows or activities. | ||
| - New workers must not duplicate logic already present in shared modules. | ||
|
|
||
| ## Enforcement | ||
|
|
||
| - PRs introducing new Temporal workers or workflows **must** follow this structure and update documentation accordingly. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,26 @@ | ||
| FROM temporalio/auto-setup:1.20.5 | ||
| FROM temporalio/auto-setup:1.27.2 | ||
|
|
||
| # Build arguments are still needed for the temporal container setup | ||
| # Keeping only those used in the HEALTHCHECK or other commands | ||
| # Set build arguments and environment variables | ||
| ARG HOST=temporal | ||
| ARG POSTGRES_SEEDS=postgresql | ||
| ARG POSTGRES_USER=temporal | ||
| ARG POSTGRES_DB_TEMPORAL_VISIBILITY=temporal_visibility | ||
| ARG DB_PORT=5432 | ||
| ARG TEMPORAL_PORT=7233 | ||
|
|
||
| RUN temporal-sql-tool --plugin postgres \ | ||
| --endpoint "$POSTGRES_SEEDS" \ | ||
| --user "$POSTGRES_USER" \ | ||
| --port "$DB_PORT" \ | ||
| --database "$POSTGRES_DB_TEMPORAL_VISIBILITY" \ | ||
| setup-schema -v 0.0 && \ | ||
| temporal-sql-tool --plugin postgres \ | ||
| --endpoint "$POSTGRES_SEEDS" \ | ||
| --user "$POSTGRES_USER" \ | ||
| --port "$DB_PORT" \ | ||
| --database "$POSTGRES_DB_TEMPORAL_VISIBILITY" \ | ||
| update-schema -d /etc/temporal/schema/postgresql/v96/visibility/versioned | ||
| ENV POSTGRES_SEEDS=$POSTGRES_SEEDS \ | ||
| POSTGRES_USER=$POSTGRES_USER \ | ||
| POSTGRES_DB_TEMPORAL_VISIBILITY=$POSTGRES_DB_TEMPORAL_VISIBILITY \ | ||
| DB_PORT=$DB_PORT \ | ||
| TEMPORAL_PORT=$TEMPORAL_PORT | ||
|
|
||
| # Add custom healthcheck using exec form | ||
| HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ | ||
| CMD ["/bin/sh", "-c", "temporal operator cluster health --address ${HOST}:${TEMPORAL_PORT} | grep -q SERVING || exit 1"] | ||
|
|
||
| # Explicitly set the user to the non-root 'temporal' user (already defined in the base image) | ||
| # Install netcat as root, then switch to non-root user | ||
| USER root | ||
| RUN apk add --no-cache netcat-openbsd | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| USER temporal | ||
|
|
||
| # Expose the gRPC port | ||
| EXPOSE ${TEMPORAL_PORT} | ||
| HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=5 \ | ||
| CMD sh -c "tctl --address temporal:7233 cluster health && nc -z temporal 7233" | ||
|
|
||
| # The entrypoint script is already defined in the base image | ||
| # Expose the gRPC port | ||
| EXPOSE 7233 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| FROM node:20-bullseye AS deps | ||
| WORKDIR /app | ||
| COPY workers/main/package*.json ./ | ||
| RUN npm ci | ||
|
|
||
| FROM node:20-bullseye AS dev | ||
| WORKDIR /app | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| ENV NODE_ENV=development | ||
| CMD ["npx", "nodemon", "--watch", "./", "--ext", "ts", "--exec", "npx", "ts-node", "src/index.ts"] | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| FROM node:20-bullseye AS build | ||
| WORKDIR /app | ||
| COPY --from=deps /app/node_modules ./node_modules | ||
| COPY workers/main/ ./ | ||
| RUN npm run build | ||
|
|
||
| FROM gcr.io/distroless/nodejs20-debian11 AS prod | ||
| WORKDIR /app | ||
| COPY --from=build /app/build ./build | ||
| COPY --from=build /app/node_modules ./node_modules | ||
|
|
||
| ARG NODE_ENV=production | ||
| ENV NODE_ENV=${NODE_ENV} | ||
|
|
||
| CMD ["node", "build/worker.js"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.