compiler: support method operations #738
Merged
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.
A small fix in the compiler to recognise
http.get()
as an operation, likeget()
This is needed to support the new http namespace in
common
, see OpenFn/adaptors#692Discussion
Is this reasonable? Is this going to break everything?
It's fine.
To date, we have assumed that any top level function call, eg,
fn()
, is an operation call. And as a result it gets relocated into the exports array.Up to today, any method calls will be left alone. Which may or may not work depending on what you're trying to do.
Where
get
is the old non-operation common.http.get.That probably won't work though, because the get wil be issued before the runtime calls the operation pipeline. It'll all be out of order.
Now, because I'm recognising method calls as operations, I'll do this:
If http.get is an operation, this will work. If it's not, well, it shouldn't be at the top of your code, should it? It shoudl be in an fn block. We do say that top level statements should be Operations (it's true, see the last line of the Job Writing Guide )