Creating a recurring event that loops indefinitely

Hello everyone, i’m currently working on an app that will be working in the background of the Freshservice platform using the serverless feature, my original idea was to use regular scheduled events for my app but considering that the limit of scheduled events is a 1000 and that i’ll be running into scalability and performance issues if i follow that path i’ve decided to use a recurring event that in turn creates the scheduled events when needed (i’ll be storing the scheduled timestamp using the data storage feature) and a handler that discards them afterwards.

The question is, how can i create a recurring event that loops indefinitely? This is the code snippet found on the developers doc in regards to the recurring scheduled event.

3 Likes

@Pavel_ACL, Thank you for brining this use case up. I would agree that the documentation is not very clear for how to create a recurring schedule. Does “frequency” indicate how many times the callback function is ran, creating 5 ticket reminders in this case? Or does it indicate that a ticket reminder is scheduled and called every “5” minutes?

I will be following this conversation to see if there can be some clearer and more concise information regarding this serverless event.

1 Like

Hey @Pavel_ACL, @Zach,

Hope you guys are doing well,

Schedulers are a tricky bunch! I’ll try to be as clear as possible in my answer,

@Pavel_ACL,

The limit for schedulers are 1 for recurring schedules and 1000 for one time schedulers, so at any point in time, your app is allowed a maximum of 1 recurring and 1000 one time schedule.

also, your approach using the data storage is the one we’ve suggested to our developers in the past as well,

by default, your recurring scheduler will keep recurring until the app is uninstalled, so as long as your recurring scheduler keeps running, it can read the data from data storage and create one time schedulers, you can just add an object with the timestamp and a boolean called recurring, instead of just the timestamp, after the one time scheduler is created from the data storage, delete the object with recurring:false in the data storage, so the recurring:true will still be persisted in the storage and will be run in the next cycle as well.

@Zach the frequecy 5 mentioned in the example means that the scheduler will run every 5 times minutes untill the app gets unistalled, it is not the number of times of the execution

Hope this helps!

Stay Safe :slight_smile:

2 Likes