-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
馃殌 Feature: Schedule an execution for the future #5489
Comments
@Silfalion First create a hourly "clock" function with CRON syntax Next, create a DB collection of documents, where each document has two fields: executionStartTime and functionName. You can also add additional fields for function parameters if you need this complexity. On each tick of the clock function, it will read all the documents in the collection and parse the received records. If a record contains execution time which is in the past, the clock function will call an execution of the function that the record points to (with params from the record if you implemented this) and then deletes that document from the collection, because the task has been executed. You can also implement "executeInterval", which causes the clock to update the document in the DB with the next execution time. This sounds all a lot like duplicating CRON functionality, but this allows you to set "CRON" tasks over the internet, if you implement another function which the user is able to call to insert execution tasks into the scheduler collection. The way I see it, it does require a bit of work to implement, but it's already possible to achieve with existing capabilities. |
Thought of that at the beginning but the schedule of the task has to be very precise and execute at the specified time. An every minute cron would be the solution right now but that feels like a lot of executions. |
@Silfalion |
That's exactly my point. A cron that checks when to execute a function is not the same as a cron that executes a function that checks if it should execute a task. There is an important overhead. |
@Silfalion |
Wait... I think we're talking about the same thing in a different way. I meant that the solution you described earlier is not desirable because it is setup by the user, but it is how it would be made inside Appwrite as you pointed out, this issue is about requesting this feature to be included in Appwrite itself Concerning the overhead, do you mean that if I create an Appwrite function with say python, to execute the solution you described, the computational load of executing the function into the runtime on every minute would be equivalent to Appwrite doing by itself? |
Appwrite uses Resque internally to queue jobs. Resque is faster than doing it yourself in cloud functions, but the difference is insignificant. There would be a noticeable performane drop if you had to schedule millions of tasks each minute by one Appwrite container. If you scale Appwrite correctly with Docker Swarm, which you are supposed to do anyways, then this becomes a non-issue. |
Hm I see, didn't know Appwrite runtimes are that efficient. Well thank you for the information and your detailed explanation earlier. I may go with that approach since it's not as slow as I thought it was |
馃敄 Feature description
So the objective of this issue is to suggest the introduction of a programmatically settable task scheduler for functions.
馃帳 Pitch
Right now function schedule is only set at the function creation and can only be changed in a way that overrides the previous schedule.
The suggestion would be to have a variable, as @Meldiron proposed(on Discord), for the execute method that would contain a datetime. The function would execute at that precise time.
This would allow to have for example 5 executions planed for a function with different inputs without changing the initial frequency of the function.
Another very interesting feature would also be, as Mattias Aabmets(Discord) suggested, to have yet another variable containing a cron for tasks for which the logic(function code) is known but frequency is erratic.
An example that would illustrate these 2 suggestions would be a reminder app. The first reminder that would take advantage of the first suggestion is setting up a datetime one day prior to a meeting to prep for it.
The second aspect of the example would be a reminder that rings me every few days(CRON) for my morning sport routine.
Right now I find myself needing to have a mini server that hit a function endpoint at a specific frequency/date that I set through the server's Api to emulate this feature , and I think it would be a powerful addition to appwrite if bundeled directly into it.
Looking forward to hearing your thoughts:)
馃憖 Have you spent some time to check if this issue has been raised before?
馃彚 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: