// 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.
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.
// 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 New(coordinationStore storage.Store, interval time.Duration) *Manager {
	if interval <= 0 {
		interval = defaultCheckInterval
	}
	s := &Manager{
		interval:          interval,
		done:              make(chan struct{}),
		logger:            log.New(loggerModule),
		coordinationStore: coordinationStore,
		instanceID:        uuid.New().String(),
		tasks:             make(map[string]*registration),
	}
	s.Lifecycle = lifecycle.New("task-manager",
		lifecycle.WithStart(s.start),
		lifecycle.WithStop(s.stop))
	return s
}
func New ( coordinationStore storage . Store , interval time . Duration ) * Manager { if interval <= 0 { interval = defaultCheckInterval } s := & Manager { interval : interval , done : make ( chan struct { } ) , logger : log . New ( loggerModule ) , coordinationStore : coordinationStore , instanceID : uuid . New ( ) . String ( ) , tasks : make ( map [ string ] * registration ) , } s . Lifecycle = lifecycle . New ( " " , lifecycle . WithStart ( s . start ) , lifecycle . WithStop ( s . stop ) ) return s }
New returns a new task manager.
New returns a new task manager .