Comments (11)
Sure thing, I'll split them out as children of this one. I mostly started writing this as a collection of ideas for discussion and it's sort of expanded from that and now probably warrants being broken down for more concise discussions.
from azure-functions-nodejs-worker.
Added two more ideas after doing some more experiments with a more complex application
from azure-functions-nodejs-worker.
we could write hooks that are simplified across the different programming models.
Can you expand on this? Our plan was to discourage people from using hooks from the worker directly. We want to keep the worker as a backwards-compatible, barebones api and I think we'd put most of the features you're asking for in the library package. Azure/azure-functions-nodejs-library#7
from azure-functions-nodejs-worker.
The current folder-based approach for Functions isn't going to be going away, so there'll be a need to support writing something in that manner as well as something that leverages the library package.
Let's say you're building a library to work with MongoDB. You'd add a hook that establishes the connection before an invocation, but since it's a generic library you wouldn't want to tie it to any specific approach to writing Functions. So you need a generic way to provide the Mongo connection, but there isn't a way to do that at present.
from azure-functions-nodejs-worker.
The folder-based approach can still be used in conjunction with the library package (usage here). v4 is the priority for adding hooks, but I think we were still planning on adding them to v3 of the package.
To me, the open question is how much we want to support the scenario you mention where a generic library doesn't want to tie themselves to a specific major version of the library package. I'm open to ideas, but hesitant to add a bunch of stuff in the worker. We really want to keep this api barebones and punt all the fancy/nice logic to the library packages.
from azure-functions-nodejs-worker.
Would there be much need to change the hooks in the worker though? If we were to leverage hookData
then it's already there, it's just passing that to the invocation channel rather, which is admittedly a change but it's then downstream of the channel to do something with that argument.
Otherwise if we made the types more obvious then it'd be apparent that the invocationContext
could be used for it (which is the approach I've taken).
from azure-functions-nodejs-worker.
Would there be much need to change the hooks in the worker though?
I'm confused, because I thought all the above requests were for the worker. Perhaps this would be easier if we split this into separate issues. Here is how I would split it up and the repo I think each should be assigned to:
- Evolving the types - worker
- Adding more richness to HookContext (everything except hook filters) - library
- Hook filters - library (I think this one deserves its own discussion)
- Pass data from hooks to Functions - library
- Ability to cancel Function runs - worker
I'll give you first crack at splitting the issues up, but I'm happy to do it myself if that's easier for you.
from azure-functions-nodejs-worker.
Regarding the HookContext and filtering - is that something that would live in library or in the worker?
Is the "plumbing" needed for that is only in the library, won't we be restricting the feature to only work in that implementation and any other implementations that get created would have to replicate it? After all, the things you'd likely filter on (name of function, trigger type, additional input bindings, etc.) are common across all implementations of a library.
from azure-functions-nodejs-worker.
Filtering is already possible which is why I don't think we need to do anything in the worker. Things like the name of the function, trigger type, etc. are already available on the invocationContext and users can filter themselves with a simple if
case. I acknowledge we could make filtering easier, but the design for that will be pretty subjective and thus I feel like that discussion belongs in the library.
At the end of the day, we want people directly referencing the library, so no they shouldn't have to replicate anything. We don't want people using the core api directly except in very rare cases.
from azure-functions-nodejs-worker.
Oh, I didn't realise that all that was available off the invocationContext - possibly with #665 can help address the discoverability of that.
from azure-functions-nodejs-worker.
Closing this since it's been split up into individual issues
from azure-functions-nodejs-worker.
Related Issues (20)
- context.debug threw error HOT 2
- Javascript function with service bus trigger delivering byte message HOT 2
- Global `require` overwriting doesn't play nice with applicationinsights 2.5.1+ HOT 4
- Intermittent unknown error, lstat 'D:\home'
- Entry point errors should block app from running
- Increase timeout for `workerInit` and `functionEnvironmentReload` requests
- Create document that describes how to fix Did not find functions with language [node] HOT 1
- System.TimeoutException: The operation has timed out. at Microsoft.Azure.WebJobs.Script.Grpc.GrpcWorkerChannel.PendingItem.OnTimeout()
- Node 18; Func v4; VSCode on macOS: "No job functions found. Try making your job classes and methods public." HOT 3
- Create documentation that describes how to troubleshoot and fix `'0 functions loaded'` HOT 2
- A function can only be registered during app startup. HOT 3
- Support Node 20 HOT 1
- Azure Functions in a monorepo (Node.js) HOT 2
- Test - disregard HOT 1
- Download file from Azure Blob Storage hangs when retrieving final 1-2 blocks HOT 7
- Settings on serviceBus.clientRetryOptions is not upheld for serviceBusTopic triggers on the node worker HOT 2
- Azure function and Kudu console NODE version mismatch in linux OS azure function. HOT 8
- Node.js v4 migration - .funcignore additiona of .tsconfig.json HOT 3
- Worker init and func env reload pointing to the same app fails to register functions HOT 1
- Unable to debug azure nodejs function locally HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-nodejs-worker.