feat: add Jobs/Scheduler server callback handler (Alpha1)#772
Open
nelson-parente wants to merge 4 commits intodapr:mainfrom
Open
feat: add Jobs/Scheduler server callback handler (Alpha1)#772nelson-parente wants to merge 4 commits intodapr:mainfrom
nelson-parente wants to merge 4 commits intodapr:mainfrom
Conversation
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>
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
- 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>
c0daff4 to
057a481
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
addJobEventHandler(name, handler)— register a callback for job triggers from the sidecarAppCallbackAlpha.OnJobEventAlpha1, stripsjob/prefix from method fieldPOST /job/{name}Express route per handlerAddJobEventHandlerpatternPart 2 of 2 for the Jobs building block (P2).
Implementation Details
GRPCServerImpl: replaced no-oponJobEventAlpha1stub with dispatch logic (handler map,job/prefix stripping,Anydeserialization)HTTPServerJobs: registers Express POST route with 60s timeout, 500 on handler errorDaprServer: exposesserver.jobs.addJobEventHandler(name, cb)Test plan
tsc --noEmitpasses (zero type errors)Relates to #667.
Signed-off-by: Nelson Parente nelson_parente@live.com.pt