Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions with props and response #1199

Closed
mediengestadler opened this issue May 26, 2021 · 9 comments
Closed

Functions with props and response #1199

mediengestadler opened this issue May 26, 2021 · 9 comments
Assignees

Comments

@mediengestadler
Copy link

馃殌 Feature

Hi,
first of all: I love appwrite! Great work you do!
Now to my idea. I think it's useful, if you can execute a function via the API with properties and gives a result. So you can hide important business logic.

Have you read the Code of Conduct?

Yes

Pitch

We have the specification, that we have to generate a hierarchical structure of our employees. They are all in one table and have a name and the id of her supervisor. With that we want to generate the whole hierarchical structure from the current user to the top, but we don't want to read all users every time and filter that via JS.

@eldadfux
Copy link
Member

In v0.8 we introduced a new data param here https://appwrite.io/docs/client/functions?sdk=web#functionsCreateExecution the data param was designed to allow you to pass any type of payload for your function to digest. @mediengestadler Let me know if this helps.

@alexweininger
Copy link
Contributor

I think I've seen other users request for this before. It would be super useful to be able to both pass data in AND get a response from cloud functions.

@mediengestadler
Copy link
Author

Hi @eldadfux, to pass data in there is an option, but at the moment you just get as response the status and not a custom response. Thats what I meant. Sorry for my bad english :)

@eldadfux
Copy link
Member

@mediengestadler @alexweininger yes, we currently support only async execution of functions due to security restrictions. We just didn't want to expose the docker socket stream directly on the API container (the appwrite container).

That said, we also have good news. We already have an experimental PR where we handle function execution through Docker HTTP API and not from the Docker socket. This will help us reduce the shell latency we have today and allow us to control runtime environments without exposing the host docker socket, and allow synced execution where the returned object could return the stdout + stderr outputs when execution completed.

@eldadfux eldadfux added this to To do in Backlog Jun 1, 2021
@eldadfux eldadfux moved this from To do to In progress in Backlog Jun 1, 2021
@eldadfux eldadfux self-assigned this Jun 1, 2021
@DiegoBM
Copy link

DiegoBM commented Jun 1, 2021

All up for sync execution! For tasks and hooks I reckon the async behaviour is all right, but for Client executed functions, I can't see polling for results scaling very well, if you have hundreds of users hammering your server asking if the function completed the execution in order to get the result (will that in fact trigger the abuse rules?).
What is the recommended flow for dealing with functions and getting results at the moment? I presume that it includes some delay among requests for results, but it would be good to know if there are any recommendations, what I've seen so far is solutions re-requesting immediately in a recursive manner until the status changes to completed which leads to the initial assumption when you multiply that by hundreds or thousands of clients.

Also, will this new Docker HTTP API implementation open the door for request/response type of functions as well? I understand that it does not adapt to all types of behaviours (hooks, cron) or runtimes, but maybe there is a way to pipe the request and response streams that triggered the function (the same way we get other streams like the IO streams), if it was user triggered by request? Just wondering.

@eldadfux
Copy link
Member

eldadfux commented Aug 6, 2021

We are currently working on this issue, and you are all welcome to comment on this RFC to allow both sync and async execution of functions: appwrite/rfc#30

@TorstenDittmann TorstenDittmann added this to In progress in Service / Functions Sep 30, 2021
@eldadfux
Copy link
Member

Update: 15-01-2022

This issue is in advanced stages and is expected to be available in Appwrite 0.13

@eldadfux eldadfux removed this from In progress in Backlog Jan 15, 2022
@DiegoBM
Copy link

DiegoBM commented Jan 15, 2022

Fantastic news!

@TorstenDittmann
Copy link
Contributor

We just released 0.13 and this should be fixed 馃憤馃徎

You can find the announcement here.

Thank you a lot for reporting this 馃檹馃徎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Service / Functions
  
In progress
Development

No branches or pull requests

5 participants