Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
Manager manages scheduled tasks which are run by exactly one server instance in an Orb domain.
func New ¶
New returns a new task manager. coordinationStore is used for ensuring that only one Orb instance within a cluster has the duty of running scheduled tasks (in order to avoid every instance doing the same work, which is wasteful). Every Orb instance within the cluster needs to be connected to the same database for it to work correctly. Note that when initializing Orb servers (or if the Orb server with the duty goes down) it is possible for multiple Orb instances to briefly assign themselves the duty, but only for one round. This will automatically be resolved on the next check and only one will end up with the duty from that point on. This situation should not be of concern since a task should expect this situation. You must register each task you want this service to run on using the Register method. Start must be called to start the service and Stop should be called to stop it.
func (*Manager) InstanceID ¶
InstanceID returns the unique ID of this server instance.
func (*Manager) RegisterTask ¶
RegisterTask registers a task to be periodically run at the given interval.
func (*Manager) RegisterTaskEx ¶
func (s *Manager) RegisterTaskEx(id string, defaultInterval time.Duration, task func() time.Duration)
RegisterTaskEx registers a task to be periodically run at the given interval. The task returns an override of the default interval. For example, if 5s is returned then the task will run again in 5 seconds. If 0 is returned then the task will run at the default interval.