-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add async
/await
parallel steps, unify createFunction
, clean examples
#45
Merged
Conversation
This file contains 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
We were previously throwing the serialization error here accidentally.
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
January 27, 2023 17:21
48e0e75
to
756b85b
Compare
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
January 27, 2023 20:32
5596e0f
to
e242f29
Compare
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
January 27, 2023 20:59
e242f29
to
eff8f4e
Compare
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
February 1, 2023 14:49
4f493ca
to
5c1a2e9
Compare
If the function is returning a value, then it can't create any more steps except by resolving or rejecting existing ones. If it does that, we capture any next steps by stepping through the existing stack loop. With this, we _can_ smartly identify when all operations in a function have been completed via success or failure, which is awesome! With this change, we keep returning `206 Partial Content` until every Promise is settled, at which point that single, final request will return `200 OK`.
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
February 3, 2023 14:15
9871e39
to
1bb3c73
Compare
jpwilliams
force-pushed
the
async-await-parallel-steps
branch
from
February 3, 2023 18:35
3c6741f
to
4fcf0f6
Compare
jpwilliams
added a commit
that referenced
this pull request
Feb 13, 2023
## Summary Approximately measures performance during function execution and returns a `Server-Timing` header to the executor, e.g.: ``` Server-Timing: handler;dur=0, memoising;dur=1, running-step;dur=164 ``` We can add to and tweak what we want to see here, but it should provide a sane method of approximately measuring some more SDK performance points. ## Related - #45
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.
Breaking changes
Function creation helpers removed
The following function creation methods have been removed and should be replaced by using
Inngest#createFunction
:createFunction
createScheduledFunction
createStepFunction
Inngest#createScheduledFunction
Inngest#createStepFunction
Step functions are now asynchronous
In order to provide the full power of asynchronous JavaScript, step functions are now required to be async functions, and all step tooling will return promises instead of synchronously.
If you're using TypeScript, you'll be guided through the changes at each stage. For example, trying to access
.id
of the newPromise<User>
will throw an error telling you that it must first be awaited.This would be converted to the following:
Custom handlers require a
stepId
In order to provide the parallel functionality in this PR, all handlers created using
InngestCommHandler
must provide astepId
parameter when attempting to run a function. This should be accessed via the query string using the exportedqueryKeys.StepId
enum.run: async () => { if (req.method === "POST") { return { fnId: url.searchParams.get(queryKeys.FnId) as string, + stepId: url.searchParams.get(queryKeys.StepId) as string,
Features
Pass functions to wrap as retriable steps
When creating a function, you can now pass a
fns
key to automatically wrap all found functions intools.run()
step tooling, automatically providing your existing functionality with retries and durability.Fixes
user
key in event payloads can now be any value, to ensure conflicting generated events are accepted; see Add optional email, external_id, etc. user properties to the event type #87 for further discussionRelated changes/issues based on this PR
tools.sendEvent()
to step function tooling #75Server-Timing
headers to HTTP responses #76onError
handler torun
which is called when a step permanently fails #43SDK changes
async
createFunction
,createScheduledFunction
, andcreateStepFunction
under a singlecreateFunction
methodPreserve complex client-lesscreateFunction
helpererror
as well asdata
.then()
,try/catch
, etc) in step functions without gotchasCreate a newStepOpCode
for a no-op other thanNone
We just return an empty array.
tools.run()
Add ability to pass steps in as "just functions" to anew Inngest()
client, which is merged with any steps passed directly toinngest.createFunction()
stepId
query param instead of op position codesStepPlanned
(or similar) op code for back compatstep
alias fortools
and deprecatetools
Examples
See examples