Sign In Register

How can we help you today?

Start a new topic

Scheduler maximum seconds

I am using a scheduler to expire a feature for a player in either 1 hour, 1 day, 7 days or 30 days depending on how much in game currency they spend on the feature. For this I decided to use a scheduler. This works as expected for 1 hour, 1 day and 7 days:


scheduler.inSeconds("EXPIRE_SIDEKICK", seconds, {SIDEKICK_ID: id}); 

scheduler.inSeconds("EXPIRE_SIDEKICK", 60 * 60, {SIDEKICK_ID: id}); // 1 hour
scheduler.inSeconds("EXPIRE_SIDEKICK", 24 * 60 * 60, {SIDEKICK_ID: id}); // 1 day
scheduler.inSeconds("EXPIRE_SIDEKICK", 7 * 24 * 60 * 60, {SIDEKICK_ID: id}); // 7 days

 

However when I try to set the scheduler for 30 days "EXPIRE_SIDEKICK" event is triggered immediately. This leads me to wonder, is there a limit to the number of seconds that a scheduler can wait?

 

scheduler.inSeconds("EXPIRE_SIDEKICK", 30 * 24 * 60 * 60, {SIDEKICK_ID: id}); // 30 days

 




You won't believe this, but I had the same question a couple of weeks back and experimentally figured out that the limit is 2147483 seconds. If you add one more second, the event triggers immediately. I requested a documentation patch from the GameSparks team to ensure that this is properly stated. 


I think your workaround for this could be to store an expiration date in the (sidekick) object itself, and in a WEEKLY module, you then check all those objects that have an expiration date between "now" (that is, when the WEEKLY gets run) and "one week from now". Make sure that you account for some overlap (i.e. a couple of minutes), because I don't think there will be any guarantee that the WEEKLY is always executed at the exact same time if the server load is heavy. You could do that by planning all expirations for the next 8 days and registering the fact that the scheduled job has been created against the object itself.


You could, of course, also do this in a DAILY module. That would reduce the number of objects you need to handle each day, which might help - I'm not sure if the scheduled jobs have a maximum execution time, but for normal requests it's 30 seconds.

Thanks for sharing your findings Rene. I agree with your suggestion of using the WEEKLY or DAILY, I may well do that.

Well that number makes sense in the context of 1000 milliseconds making the max the max signed int value.


1 person likes this

Doh, how did I not see this. Apparently, it's a 32-bit signed integer that gets multiplied by 1000 to determine milliseconds.


1 person likes this

Hi All


We will be fixing this in our next release.


Regards

Katie

Login to post a comment