-
Notifications
You must be signed in to change notification settings - Fork 0
docs: align examples with actual Future/Result implementation patterns #84
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
Conversation
- Update Getting Started guide with correct activity implementation patterns - Fix Activity Handlers guide to show Future/Result pattern - Update Worker Implementation guide with proper error handling examples - Correct Result Pattern guide to clarify activities vs workflows - Fix Client Usage guide to show Future/Result pattern correctly - Update package READMEs with consistent examples - Fix main README with proper example Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
- Remove references to non-existent createWorker function - Update to use standard Worker.create from @temporalio/worker - Fix child workflow examples to show Result pattern - Update sample READMEs to reflect actual samples - Remove references to non-existent worker-boxed sample Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
- Update index.md with correct Worker.create usage - Fix client example to show Future/Result pattern - Add proper Connection setup in client example - Ensure all worker examples use standard Temporal Worker API Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
Changed all workflow implementations from:
implementation: async (context, input) => {}
to:
implementation: async ({ activities, executeChildWorkflow, ... }, input) => {}
This follows the codebase convention of destructuring the context parameter directly.
Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
|
@copilot format because CI is KO |
Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
|
@copilot retry |
Run oxfmt to fix CI formatting issues. Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
Updated packages/worker/README.md to use destructured context parameter pattern:
- Changed from: implementation: async (context, input) => {}
- Changed to: implementation: async ({ activities }, input) => {}
This ensures consistency across all documentation examples.
Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates all documentation and README files to accurately reflect the current codebase implementation, specifically around the Result/Future pattern usage, worker creation, and context destructuring.
Key Changes:
- Updated all activity examples to show the
Future.fromPromise()pattern withActivityErrorwrapping - Fixed worker creation examples to use standard
Worker.create()instead of the non-existentcreateWorkerfunction - Updated workflow implementations to destructure context parameters
- Clarified that workflows receive plain values from activities (Result unwrapped by framework) while child workflows use the Result pattern
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/index.md | Updated client and worker examples to show Result/Future pattern and correct Worker.create usage |
| website/docs/guide/worker-usage.md | Removed createWorker references, updated child workflow examples to show Result pattern |
| website/docs/guide/worker-implementation.md | Added Future/Result pattern to activities, clarified workflow receives plain values, destructured context |
| website/docs/guide/result-pattern.md | Clarified activities use Future/Result internally while workflows use try/catch for activity calls |
| website/docs/guide/getting-started.md | Fixed worker setup and client examples to show Result/Future pattern |
| website/docs/guide/entry-points.md | Destructured context in workflow examples |
| website/docs/guide/client-usage.md | Updated to show Future/Result pattern from client perspective |
| website/docs/guide/activity-handlers.md | Updated all activity examples to show Future/Result pattern with ActivityError |
| samples/order-processing-worker/README.md | Updated description to reflect Result/Future pattern usage |
| samples/order-processing-client/README.md | Fixed references to non-existent worker-boxed sample, updated to worker-nestjs |
| packages/worker/README.md | Added Future/Result pattern to activities, removed createWorker, destructured context |
| packages/client/README.md | Fixed client creation to include Client instance |
| README.md | Updated quick example to show Future/Result pattern for activities |
Comments suppressed due to low confidence (1)
website/docs/guide/worker-usage.md:1
- The variable name 'handleResult' is confusing as it suggests a result when it actually contains a Result wrapping a workflow handle. Consider naming it 'handleOrError' or 'startResult' to better reflect that it's the result of starting (not the workflow result).
# Worker Usage
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Changed variable name from 'resultFuture' to 'future' across all documentation to avoid redundancy since it's already clear from context that it's a Future. Updated files: - website/docs/index.md (2 instances) - website/docs/guide/getting-started.md - website/docs/guide/client-usage.md Co-authored-by: btravers <3476441+btravers@users.noreply.github.com>
Documentation and Examples Review - Complete ✅
All Completed Tasks:
Getting Started Guide (
website/docs/guide/getting-started.md)Activity Handlers Guide (
website/docs/guide/activity-handlers.md)Worker Implementation Guide (
website/docs/guide/worker-implementation.md)Worker Usage Guide (
website/docs/guide/worker-usage.md)Result Pattern Guide (
website/docs/guide/result-pattern.md)Entry Points Guide (
website/docs/guide/entry-points.md)Client Usage Guide (
website/docs/guide/client-usage.md)Client README (
packages/client/README.md)Worker README (
packages/worker/README.md)createWorkerfunctionMain README (
README.md)Sample READMEs
Homepage (
website/docs/index.md)Formatting
Summary of Changes
All documentation and README files have been reviewed and updated to reflect the actual code implementation:
Future.fromPromise()with.mapError()and.mapOk()({ activities }, input) => {}- ALL instances fixedFuture<Result>from workflow execution methodsWorker.create()from@temporalio/workerOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.