/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
package scheduler
import (
"errors"
"fmt"
"reflect"
"time"
"zabbix.com/internal/agent"
"zabbix.com/pkg/itemutil"
"zabbix.com/pkg/log"
"zabbix.com/pkg/plugin"
"zabbix.com/pkg/zbxlib"
)
// task priority within the same second is done by setting nanosecond component
const (
priorityConfiguratorTaskNs = iota
priorityStarterTaskNs
priorityCollectorTaskNs
priorityWatcherTaskNs
priorityExporterTaskNs
priorityStopperTaskNs
)
// exporterTaskAccessor is used by clients to track item exporter tasks .
type exporterTaskAccessor interface {
task() *exporterTask
}
// taskBase implements common task properties and functionality
type taskBase struct {
plugin *pluginAgent
scheduled time.Time
index int
active bool
recurring bool
}
func (t *taskBase) getPlugin() *pluginAgent {
return t.plugin
}
func (t *taskBase) getScheduled() time.Time {
return t.scheduled
}
func (t *taskBase) getWeight() int {
return 1
}
func (t *taskBase) getIndex() int {
return t.index
}
func (t *taskBase) setIndex(index int) {
t.index = index
}
func (t *taskBase) deactivate() {
if t.index != -1 {
t.plugin.removeTask(t.index)
}
t.active = false
}
func (t *taskBase) isActive() bool {
return t.active
}
func (t *taskBase) isRecurring() bool {
return t.recurring