Back

how to execute an exact function in a dart cloud function

  • 0
  • Cloud
dammy
17 Jun, 2024, 19:47

Really 😮

TL;DR
Developers are struggling to execute a specific function in a Dart cloud function and differentiate between different events triggering the function. They are discussing best practices and ways to improve the handling of various features within the cloud function instance. Splitting up the code and handling functions based on events are suggested solutions to achieve better execution control.
Joshi
17 Jun, 2024, 19:48

I personally would split up the code but I would just differentiate based on the event. See here https://appwrite.io/docs/advanced/platform/events

Kenny
17 Jun, 2024, 19:48

But if they all use the same trigger how would you differentiate then?

dammy
17 Jun, 2024, 19:48

nice idea, but still this particular function does so many things

Joshi
17 Jun, 2024, 19:49

Can you elaborate what your function does?

dammy
17 Jun, 2024, 19:50

that's just it, except if all the functions have different events but still, it will still need to tell the cloud function instance what function to execute

except if you want all functions to execute either asynchronously or all at once, which is far from the goal

Joshi
17 Jun, 2024, 19:50

I have written a method in my starter function which can differiantiate the event. What type it is and the event item id (like document id, file id, etc.)

dammy
17 Jun, 2024, 19:51

writing to database after account creation, fetching data after login, writing to database after transactions are successful, communication with third party API and more

Joshi
17 Jun, 2024, 19:51

Account creation != login, no?

dammy
17 Jun, 2024, 19:51

I still don't get picture you're trying to paint 🎨

dammy
17 Jun, 2024, 19:51

???

Joshi
17 Jun, 2024, 19:52

Does your user register via the official method or via your function?

dammy
17 Jun, 2024, 19:52

Via official method

dammy
17 Jun, 2024, 19:52

But I don't want to write to the database via client app

dammy
17 Jun, 2024, 19:52

But all done in backend, to follow best practices

Joshi
17 Jun, 2024, 19:52

Yeah, because if a user registers it triggers this event "users..create" and when the user logins it triggers this "users..sessions.*"

Joshi
17 Jun, 2024, 19:53

so user create it not the same as login

Joshi
17 Jun, 2024, 19:53

it is two different events

Joshi
17 Jun, 2024, 19:53
dammy
17 Jun, 2024, 19:54

I mean one cloud function to have more than 30 different features that it does (as dart function)

dammy
17 Jun, 2024, 19:55

I know about all these, but this will be best when I have different cloud functions for different services and features.

Idk if you got my motive?

Joshi
17 Jun, 2024, 19:56

Kinda and kinda not I think. Let me reread real quick. I think putting too many features within a single function makes it too complex unesseccarily. Each function should just do a certain thing or flow (like registration flow)

dammy
17 Jun, 2024, 19:57

yes, this is because I can only create 5 cloud functions

Joshi
17 Jun, 2024, 19:58

Yeah ok that explains it. Are you in production already? If not I would just spin up appwrite locally on your pc with docker

dammy
17 Jun, 2024, 19:59

I tried using local appwrite instance, it ate up weeks of my time.

I was unable to communicate with it via docker despite looking for solutions 😞

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more