** Copyright (C) 2001-2023 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.
// watch package provides utility functionality for easier Watcher plugin implementation.
// Watcher plugin listens for events specified by the item requests and comnverts those
// events to item values. This package handles event source initialization/deinitialization,
// event filtering and conversion to item values/errors.
"git.zabbix.com/ap/plugin-support/plugin"
// EventSource generates events by calling Manager.Notify() method and passing arbitrary
// data. The data is converted to string values by event filter that was created by the
// event source during Manager update.
type EventSource interface {
// initialize event source and start generating events
// stop generating events and release internal resources allocated by event source
// create new event filter based on item key
NewFilter(key string) (filter EventFilter, err error)
// EventProvider interface provides methods to get event source by item key. An new or existing
// event source can be returned. EventProvider is required to create Manager instance.
type EventProvider interface {
EventSourceByKey(key string) (EventSource, error)
// EventFilter has two responsibilities. The first is to convert data to a string value.
// The second is optional - based on internal filter parameters (item key for example)
// it can make the data to be ignored by returning nil value.
type EventFilter interface {
// Process processes data from event source and returns:
// value - data is valid and matches filter
// nothing - data is valid, but does not match the filter
Process(data interface{}) (value *string, err error)
// eventWriter links event filter to output sink where the filtered results must be written
type eventWriter struct {