//Introduces a new event into the handler for processing
//and sending to relevant plugins.
2284
func (ph Manager) Dispatch(e Event, args Args) error {
	return ph.dispatch("local", e, args)
}
1255148
func WithEventHandler(handler events.Handler) Option {
	return func(c *Config) Option {
		old := c.handler
		c.handler = handler
		return WithEventHandler(old)
	}
}
711978
func NewEventHandler(event string, fn interface{}) (events.ThrustEventHandler, error) {
	return events.NewHandler(event, fn)
}
1113222
func (s *Sentry) Event(logEvent *event.Event) error {
	message := logEvent.Message
	if err, ok := logEvent.FlatFields["error"]; ok {
		message = fmt.Sprintf("%s: %v", message, err)
	} else if err, ok := logEvent.FlatFields["err"]; ok {
		message = fmt.Sprintf("%s: %v", message, err)
	}

	s.RLock()
	packet := raven.NewPacket(message)
	packet.Logger = "sawmill"
	packet.EventID = s.idPrefix + strconv.FormatInt(int64(logEvent.Id), 10)
	packet.Timestamp = raven.Timestamp(logEvent.Time)
	packet.Level = ravenLevels[logEvent.Level]
	for k, v := range logEvent.FlatFields {
		packet.Extra[k] = v
	}

	if len(logEvent.Stack) != 0 {
		packet.Culprit = logEvent.Stack[0].Package + "." + logEvent.Stack[0].Func
	}

	// translate logEvent.Stack into raven.Stacktrace
	packet.Interfaces = append(packet.Interfaces, ravenTrace(s.repoRoot, logEvent.Stack))

	_, errChan := s.client.Capture(packet, nil)
	err := <-errChan
	s.RUnlock()
	return err
}
941263
func NewEventHandler(eventHandler eh.EventHandler) *EventHandler {
	h := &EventHandler{
		EventHandler: eventHandler,
		eventsCh:     make(chan data),
		errCh:        make(chan error, 1),
	}

	go h.run()

	return h
}
905427
func (az *Cloud) Event(obj runtime.Object, eventtype, reason, message string) {
	if obj != nil && reason != "" {
		az.eventRecorder.Event(obj, eventtype, reason, message)
	}
}
789825
func (l *Logger) HandleEvent(ctx context.Context, event eh.Event) error {
	log.Println("event:", event)
	return nil
}
645372
func (h EventHandlerFunc) HandleEvent(ctx context.Context, e Event) error {
	return h(ctx, e)
}
1291536
func (c *Client) NewEvent() *Event {
	c.ensureTransmission()
	c.ensureBuilder()
	return c.builder.NewEvent()
}
624700
func NewEvent(name string, data interface{}) *Event {
	return &Event{Name: name, Data: data}
}
81463
func (em *EventManager) NewEvent(evtype, evselector string) (EventSubs, bool) {
	eo := BuildEventID(evtype, evselector)

	if em.HasEvent(eo) {
		ed, _ := em.GetEvent(eo)
		return ed, false
	}

	emo := NewEventSub(evtype, evselector)

	em.AddEvent(emo)
	return emo, true
}
1196854
func (watcher *RecursiveWatcher) handleEvent(event *fsnotify.FileEvent) {
	if event.IsCreate() {
		watcher.handleCreate(event)
	}

	e := Event{
		FileEvent: event,
	}

	watcher.Events <- e
}
432870
func (p Protos) AddEventHandler(msgType string, handler func(...interface{})) error {
	switch msgType {
	case EventNewMessage:
		eventHandlers[EventNewMessage] = handler
	case EventTimer:
		eventHandlers[EventTimer] = handler
	case EventTerminate:
		eventHandlers[EventTerminate] = handler
	default:
		return fmt.Errorf("Failed to add event handler. Message type %s is not supported", msgType)
	}
	return nil
}
40034
func (handler *WriterHandler) Event(logEvent *event.Event) error {
	//handler.Output.Write([]byte(fmt.Sprintf("%#v\n", event)))
	var templateBuffer bytes.Buffer
	handler.Template.Execute(&templateBuffer, formatter.EventFormatter(logEvent))
	templateBuffer.WriteByte('\n')
	handler.Output.Write(templateBuffer.Bytes())

	return nil
}
19276
func (ac *AppClient) Event(event *omaha.EventRequest) <-chan error {
	errc := make(chan error, 1)
	url := ac.apiEndpoint
	req := ac.NewAppRequest()
	app := req.Apps[0]
	app.Events = append(app.Events, event)

	go func() {
		appResp, err := ac.doReq(url, req)
		if err != nil {
			errc <- err
			return
		}

		// BUG: CoreUpdate does not send event status in response.
		_ = appResp
		/*if len(appResp.Events) == 0 {
			errc <- fmt.Errorf("omaha: event status missing from response")
			return
		}

		if appResp.Events[0].Status != "ok" {
			errc <- fmt.Errorf("omaha: event status %s", appResp.Events[0].Status)
			return
		}*/

		errc <- nil
		return
	}()

	return errc
}
869731
func (w *Webhook) UpdateEvent() error {
	data, err := jsoniter.Marshal(w.HookEvent)
	w.Events = string(data)
	return err
}
775944
func NewEvent() *Event {
	event := new(Event)
	event.TimeMetrics = make(map[string]float64)
	event.NumberMetrics = make(map[string]uint64)
	event.BoolMetrics = make(map[string]bool)
	return event
}