Skip to content

feat: add Jobs/Scheduler server callback handler (Alpha1)#772

Open
nelson-parente wants to merge 4 commits intodapr:mainfrom
nelson-parente:feat/jobs-server
Open

feat: add Jobs/Scheduler server callback handler (Alpha1)#772
nelson-parente wants to merge 4 commits intodapr:mainfrom
nelson-parente:feat/jobs-server

Conversation

@nelson-parente
Copy link
Copy Markdown
Contributor

Summary

  • Add server-side job event handler for both gRPC and HTTP transports
  • addJobEventHandler(name, handler) — register a callback for job triggers from the sidecar
  • gRPC: dispatches via AppCallbackAlpha.OnJobEventAlpha1, strips job/ prefix from method field
  • HTTP: registers POST /job/{name} Express route per handler
  • Follows Go SDK's AddJobEventHandler pattern
  • Includes unit tests for HTTP transport

Depends on #771 — merge that first. This PR includes #771's commits and will show a clean diff once #771 lands.

Part 2 of 2 for the Jobs building block (P2).

Implementation Details

  • GRPCServerImpl: replaced no-op onJobEventAlpha1 stub with dispatch logic (handler map, job/ prefix stripping, Any deserialization)
  • HTTPServerJobs: registers Express POST route with 60s timeout, 500 on handler error
  • DaprServer: exposes server.jobs.addJobEventHandler(name, cb)

Test plan

  • tsc --noEmit passes (zero type errors)
  • Unit tests for HTTP server (route registration, dispatch, error handling, multi-handler)
  • CI validates full test suite
  • E2E tests deferred to P7

Relates to #667.

Signed-off-by: Nelson Parente nelson_parente@live.com.pt

Add the Jobs building block client for both gRPC and HTTP transports:
- schedule() — create or update a scheduled job
- get() — retrieve a job definition by name
- delete() — delete a job by name

All APIs are Alpha1, matching the Go SDK's implementation.
Includes unit tests for HTTP transport.

Relates to dapr#667.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
@nelson-parente nelson-parente requested review from a team as code owners April 21, 2026 11:16
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 0% with 179 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.82%. Comparing base (d1bf38a) to head (057a481).
⚠️ Report is 64 commits behind head on main.

Files with missing lines Patch % Lines
src/implementation/Client/GRPCClient/jobs.ts 0.00% 79 Missing ⚠️
src/implementation/Client/HTTPClient/jobs.ts 0.00% 53 Missing ⚠️
src/implementation/Server/HTTPServer/jobs.ts 0.00% 17 Missing ⚠️
...implementation/Server/GRPCServer/GRPCServerImpl.ts 0.00% 15 Missing ⚠️
src/implementation/Server/GRPCServer/jobs.ts 0.00% 7 Missing ⚠️
src/implementation/Client/DaprClient.ts 0.00% 4 Missing ⚠️
src/implementation/Server/DaprServer.ts 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              main     #772       +/-   ##
============================================
- Coverage   100.00%   24.82%   -75.18%     
============================================
  Files            1      142      +141     
  Lines            6     3895     +3889     
  Branches         1      608      +607     
============================================
+ Hits             6      967      +961     
- Misses           0     2884     +2884     
- Partials         0       44       +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Remove typeUrl from AnySchema (match other building blocks' pattern)
- fromProtoJob: fallback to string not raw Uint8Array on parse failure
- fromProtoJob: check value.length to handle empty Uint8Array
- parseDurationSeconds: throw on unrecognized format instead of silent 0
- parseDurationSeconds: use matchAll to avoid g-flag lastIndex issues
- Duration round-trip: always use seconds format for simplicity

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Add server-side job event handler for both gRPC and HTTP transports:
- addJobEventHandler(name, handler) — register a callback for job triggers
- gRPC: dispatches via AppCallbackAlpha.OnJobEventAlpha1, strips "job/" prefix
- HTTP: registers POST /job/{name} route per handler

Follows the Go SDK pattern (AddJobEventHandler).
Includes unit tests for HTTP transport.

Relates to dapr#667.

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
- Interface returns Promise<void> to match HTTP impl and binding pattern
- GRPCServerImpl.onJobEventAlpha1: add try/catch with error logging
- GRPCServerImpl.onJobEventAlpha1: use const for jobName resolution
- GRPCServerImpl.onJobEventAlpha1: check value.length for empty Uint8Array
- GRPCServerImpl.onJobEventAlpha1: fallback to string not raw Uint8Array
- HTTPServerJobs: add OPTIONS pre-flight route (consistent with bindings)

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant