I am working on a web app where users can create lists. I perform a bunch of validation server side with functions and currently I do this as follows
- Write user request to a request collection
- Collection triggers a function
- Function validates and writes to user lists collection
- User gets realtime update from user lists collection
- App updates
I want to move away from database triggering functions to making a POST request to the function directly. The examples on appwrite documentation shows server side code but not client side code (working with flutter). How am I supposed to make such a request ?
Create a function execution request ? If so how is user supposed to get response data once execution completes ?
Are you creating collections at runtime?
Not sure what you mean, which collections ? No collections are created at runtime, only documents in said collections to help trigger respective functions.
Have you seen https://appwrite.io/docs/products/functions#sdk?
Of course I have, quite a bit. The only thing I see there is to create execution but I am not sure with that how i am supposed to pass data back to the user ? From what I understand the CreateExecution will immediately return execution status and not data I might want to send back i.e., list created or failed with error etc. Not sure if I create ASYNC false execution would an await work then ? Thus wanted to ask the experts 🙂
Just to be clear I am speaking purely in a flutter context.
Yes, the async parameter is what will determine whether the execution should be processed right away and have the response populated
Sounds pretty straight forward. Will need to try. Another thing to check, since like users creating lists is a very common task that will happen quite often, any possible pitfalls with a large number of async false executions being queued ?
Synchronous executions don't get queued. The only thing is if your function hasn't executed successfully in a while, the runtime container may be removed so the next execution will be a cold start
Cold start is not a concern, my concern is, to quote a hypothetical extreme case, 100 synchronous requests on a 2 vcpu server. They will , I assume, be executed sequentially thus the await for a 100th request will be resolved once its executed say a minute or so later and with a response ? Accurate ?
No, they're all executed concurrently (up to a certain limit) just like how create document requests don't execute sequentially
Ah understood. Thanks
[SOLVED] how to make function calls from flutter webapp
Recommended threads
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...