-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allowing adaptors to extend execute #22
Comments
After thinking about this, I think it's unacceptable that old adaptors should be totally incompatible with the new runtime. I think the compiler should add the magic to export an execute function. The runtime will use the job's exported Which means automated imports probably need to look something like this:
Later, we can add intelligence to only do this for language-adaptors which we know override execute. Although this relies on the adaptor having a .d.ts really, so maybe we invert the logic and do this unless a) the package has a .d.ts and b) the d.ts does not export execute). New adaptors should still register side-effects from @openfn/runtime on import. |
Hang on, a way easier fix is just to export everything:
|
Ok, so live on If If a job exports a function called Next steps are to implement the lifecycle features described in #25. |
Some adaptors, like postgres, allow the execute function to be extended.
This will break in v2 at the moment!
What's really going on here is the adaptor wants to add setup and teardown hooks which run at the start and end of the pipeline.
I think the solution is to publish a new adaptor which is only compatible with the new runtime. The adaptor would look like this:
Whenever the adaptor is imported, it'll automatically run the setup and teardown operations at the start and end of the pipeline. it's similar to the overridden execute really, but a bit less magical.
What I like about this approach is that there's no compiler or runtime magic. v1 jobs will continue to work in the new runtime.
The only downside I can see is that the next-gen adaptor will fail in the old engine. Given that the platform can control which adaptors are loaded, I think this is probably acceptable?
It also gets a bit sticky in he new CLI because you'll need to target the CLI at the correct adaptor version. Again this is probably OK, but may rely on a good versioning strategy eg
openfn . -a @open/language-postgres@2.0.0
The text was updated successfully, but these errors were encountered: