tasks

package
v0.0.0-...-5bfa661 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(name TaskType) (func(map[string]interface{}) (TaskHandler, error), error)

Types

type HttpHandler

type HttpHandler struct {
	Port                 int
	Schema, Method, Path string
	Codes                []int
	Header               map[string]string
	ResponseHeader       map[string]string
	Jq                   string
	Timeout              time.Duration
	// contains filtered or unexported fields
}

func (*HttpHandler) Test

func (h *HttpHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails

type HttpResult

type HttpResult struct {
	Jq interface{}
}

type KEBAHandler

type KEBAHandler struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*KEBAHandler) Test

func (h *KEBAHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails

type KebaResult

type KebaResult struct {
	Addr, Serial string
}

type ModbusHandler

type ModbusHandler struct {
	Port     int
	IDs      []uint8
	Models   []int
	Point    string
	Register modbus.Register `mapstructure:",squash"`
	Values   []int
	Invalid  []int

	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*ModbusHandler) Test

func (h *ModbusHandler) Test(log *util.Logger, in ResultDetails) (res []ResultDetails)

type ModbusResult

type ModbusResult struct {
	SlaveID uint8
	Model   int         `json:",omitempty"`
	Point   string      `json:",omitempty"`
	Value   interface{} `json:",omitempty"`
}

func (*ModbusResult) Configuration

func (r *ModbusResult) Configuration(handler TaskHandler, res Result) map[string]interface{}

type MqttHandler

type MqttHandler struct {
	Port    int
	Topic   string
	Timeout time.Duration
}

func (*MqttHandler) Test

func (h *MqttHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails

type PingHandler

type PingHandler struct {
	Count   int
	Timeout time.Duration
}

func (*PingHandler) Test

func (h *PingHandler) Test(log *util.Logger, in ResultDetails) []ResultDetails

type Result

type Result struct {
	Task
	ResultDetails
	Attributes map[string]interface{} // TODO remove, only used for post-processing
}

type ResultDetails

type ResultDetails struct {
	IP           string
	Port         int           `json:",omitempty"`
	Topic        string        `json:",omitempty"`
	ModbusResult *ModbusResult `json:",omitempty"`
	KebaResult   *KebaResult   `json:",omitempty"`
	SmaResult    *SmaResult    `json:",omitempty"`
}

func (*ResultDetails) Clone

func (d *ResultDetails) Clone() ResultDetails

type SMAHandler

type SMAHandler struct {
	Timeout  time.Duration
	Password string
	// contains filtered or unexported fields
}

func (*SMAHandler) Test

func (h *SMAHandler) Test(log *util.Logger, in ResultDetails) (res []ResultDetails)

type SmaResult

type SmaResult struct {
	Serial string
	Http   bool
}

type Task

type Task struct {
	ID      string
	Type    TaskType
	Depends string
	Config  map[string]interface{}
	TaskHandler
}

type TaskHandler

type TaskHandler interface {
	Test(log *util.Logger, in ResultDetails) []ResultDetails
}

func HttpHandlerFactory

func HttpHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func KEBAHandlerFactory

func KEBAHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func ModbusHandlerFactory

func ModbusHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func MqttHandlerFactory

func MqttHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func PingHandlerFactory

func PingHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func SMAHandlerFactory

func SMAHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

func TcpHandlerFactory

func TcpHandlerFactory(conf map[string]interface{}) (TaskHandler, error)

type TaskHandlerRegistry

type TaskHandlerRegistry map[TaskType]func(map[string]interface{}) (TaskHandler, error)

func (TaskHandlerRegistry) Add

func (r TaskHandlerRegistry) Add(name TaskType, factory func(map[string]interface{}) (TaskHandler, error))

type TaskType

type TaskType string
const Http TaskType = "http"
const Keba TaskType = "keba"
const Modbus TaskType = "modbus"
const Mqtt TaskType = "mqtt"
const Ping TaskType = "ping"
const Sma TaskType = "sma"
const Tcp TaskType = "tcp"

type TcpHandler

type TcpHandler struct {
	Ports   []int
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (*TcpHandler) Test

func (h *TcpHandler) Test(_ *util.Logger, in ResultDetails) (res []ResultDetails)

Jump to

Keyboard shortcuts

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