Rate-controlled Function delay - RateScheduleService

:link: Module

The link for the module is here.

:information_source: About

This Module allows you to fire functions with set arguements in a sequence at a certain rate. This is usefull for using external APIs that have rate limits.

:open_book: API

Methods:

RateScheduleService.new()
function RateScheduleService.new(Rate:number)

Creates a new schedule object with a given rate, default rate is 1.

ScheduleObject:run()
function ScheduleObject:run()

Invokes the functions in the schedule at the ScheduleObject’s Rate. Yieldable.

Note: If the ScheduleObject has been yielded, it can only be resumed by :resume() , trying to run this after a yield would not run it.

ScheduleObject:yield()
function ScheduleObject:yield()

Yields running the schedule until ScheduleObject:resume() is run.

ScheduleObject:resume()
function ScheduleObject:resume()

Unyields the schedule.

ScheduleObject:clear()
function ScheduleObject:clear()

Clears the ScheduleObject’s schedule.

ScheduleObject:add()
function ScheduleObject:add(func:function,...)

Adds a function to the schedule, arguements can be provided.

ScheduleObject:remove()
function ScheduleObject:remove(index:number)

Removes an index from the schedule.

ScheduleObject:SetRate()
function ScheduleObject:SetRate(Rate:number)

Sets the ScheduleObject’s Rate to the one provided.

This module is deprecated and has been replaced by the FuncRate Module.

4 Likes

:hammer: Minor Update

Updated parameters for .new(), it now has an optional parameter: Capacity, default is infinite. No more schedules can be added whilst the number of existing schedules are at capacity.

New function: :SetCap(), it sets the capacity to the given number.

New function: :GetSchedules(). It returns an array of existing schedules.

What’s the unit of measure for the Rate argument of RateScheduleService.new()? Function calls per minute?

The delay between each call. But thinking of it, I should change it to function calls per miniute.

1 Like

RateScheduleService is getting deprecated!

RateScheduleService is soon to be replaced with FuncRate once it’s out. FuncRate would be a more sophisticated and extra functions.

This message would be edited once FuncRate is out to include the link.

(31 may) FuncRate released! The thread about it is here

Bumping because FuncRate has finally been released.