communicate/events/event.go

49 lines
1.2 KiB
Go
Raw Normal View History

2016-11-28 14:13:15 +09:00
package events
const (
CENTRAL_POLLING = "P"
CENTRAL_EVENT = "E"
)
const (
2016-11-28 14:46:39 +09:00
COLLECTOR_INSTALL = "/_api/collector/discovery/event/status/install"
2016-11-28 14:25:11 +09:00
2016-11-28 14:48:38 +09:00
DISCOVERY_START = "/_api/collector/event/discovery/status/start"
DISCOVERY_END = "/_api/collector/event/discovery/status/end"
2016-11-28 14:46:39 +09:00
HOST_START = "/_api/collector/discovery/event/host/status/start"
HOST_FOUND = "/_api/collector/discovery/event/host/status/found"
HOST_END = "/_api/collector/discovery/event/host/status/end"
2016-11-28 14:43:50 +09:00
2016-11-28 14:46:39 +09:00
PORT_START = "/_api/collector/discovery/event/port/status/start"
PORT_FOUND = "/_api/collector/discovery/event/port/status/found"
PORT_END = "/_api/collector/discovery/event/port/status/end"
SERVICE_END = "/_api/collector/discovery/event/service/status/end"
2016-11-28 14:13:15 +09:00
)
type URLMaker interface {
GetUrl() string
}
type Event struct {
Collector_id string
Time Timestamp
EventType string
Data interface{}
Result chan Result `json:"-"`
}
func (e *Event) GetResult() Result {
return <-e.Result
}
func NewEvent(dataType string, data interface{}) *Event {
return &Event{
Collector_id: "", // get this collector identity
Time: Now(),
EventType: dataType,
Data: data,
Result: make(chan Result),
}
}