msg

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertMsg

type AlertMsg struct {
	*SzenarioEvtMsg
	Level string
}

AlertMsg is a alert

func NewAlert

func NewAlert(m *SzenarioEvtMsg) *AlertMsg

NewAlert converts the Event to an Alert

type FileMsgItem

type FileMsgItem struct {
	ID      uuid.UUID `json:"ID"  gorm:"primaryKey;type:uuid"`
	Name    string    `json:"Name"`
	Type    mime.Type
	Size    int `json:"Size"`
	Payload []byte
}

FileMsgItem contains a file

func NewFileMsgItem

func NewFileMsgItem(name string, mtype mime.Type, payload []byte) *FileMsgItem

NewFileMsgItem creates a new FileMsgItem

func (*FileMsgItem) CalculateID

func (fmi *FileMsgItem) CalculateID()

CalculateID calculates the uuid from the file hash if needed

type IncidentMsg

type IncidentMsg struct {
	*SzenarioEvtMsg
	Type      IncidentMsgType
	Start     time.Time
	End       time.Time
	IntLevel  int    `json:"Level" gorm:"column:Level"`
	ByteState []byte `json:"State" gorm:"column:State"`
}

IncidentMsg communicates the state of the incident

func NewIncidentMsg

func NewIncidentMsg(t IncidentMsgType, m *SzenarioEvtMsg) *IncidentMsg

NewIncidentMsg creates a incident message

type IncidentMsgType

type IncidentMsgType int

IncidentMsgType idicates what type of msg it is

const (
	// OpenIncident a new incident
	OpenIncident IncidentMsgType = iota
	// UpdateIncident a existing incident
	UpdateIncident
	// CloseIncident the incident
	CloseIncident
)

func (IncidentMsgType) String

func (i IncidentMsgType) String() string

type SzenarioEvtMsg

type SzenarioEvtMsg struct {
	ID         uuid.UUID `json:"ID"`
	IncidentID string    `json:"Incident"`
	Name       string    `json:"Name"`
	Time       time.Time `json:"Time"`
	Username   string    `json:"Username"`
	Region     string    `json:"Region"`
	Errors     []string

	Counters  map[string]float64 `json:"Counters"`
	Stati     map[string]string
	Files     []FileMsgItem `json:"Files"`
	ProbeOS   string        `json:"OS"`
	ProbeHost string        `json:"Host"`
	// contains filtered or unexported fields
}

SzenarioEvtMsg contains all typicall fields

func NewSzenarioEvtMsg

func NewSzenarioEvtMsg(name string, username string, now time.Time) *SzenarioEvtMsg

NewSzenarioEvtMsg creates a SzenarioEvtMsg

func SzenarioEvtMsgFromJSON

func SzenarioEvtMsgFromJSON(b []byte) (*SzenarioEvtMsg, error)

SzenarioEvtMsgFromJSON creates a SzenarioEvtMsg

func (*SzenarioEvtMsg) AddErr

func (m *SzenarioEvtMsg) AddErr(e error)

AddErr adds a non nil error to the message

func (*SzenarioEvtMsg) AddFile

func (m *SzenarioEvtMsg) AddFile(f *FileMsgItem)

AddFile adds a file

func (*SzenarioEvtMsg) Err

func (m *SzenarioEvtMsg) Err() error

Err returns nil if there are no error and the last non nil error otherwise

func (*SzenarioEvtMsg) Errs

func (m *SzenarioEvtMsg) Errs() []string

Errs returns a slice of errors

func (*SzenarioEvtMsg) SetCounter

func (m *SzenarioEvtMsg) SetCounter(key string, val float64)

SetCounter adds or replaces a counter a counter must be int or float

func (*SzenarioEvtMsg) SetStatus

func (m *SzenarioEvtMsg) SetStatus(key string, val string)

SetStatus sets a status

Jump to

Keyboard shortcuts

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