taskmgr

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	*lifecycle.Lifecycle
	// contains filtered or unexported fields
}

Manager manages scheduled tasks which are run by exactly one server instance in an Oak domain.

func New

func New(coordinationStore storage.Store, interval time.Duration) *Manager

New returns a new task manager. coordinationStore is used for ensuring that only one Oak 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 Oak instance within the cluster needs to be connected to the same database for it to work correctly. Note that when initializing Oak servers (or if the Oak server with the duty goes down) it is possible for multiple Oak 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

func (s *Manager) InstanceID() string

InstanceID returns the unique ID of this server instance.

func (*Manager) RegisterTask

func (s *Manager) RegisterTask(id string, interval time.Duration, task func())

RegisterTask registers a task to be periodically run at the given interval.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL