// Event asynchronously sends the given omaha event.
// Reading the error channel is optional.
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
}
694171
func (me *Event) C() <-chan struct{} {
	if me.ch == nil {
		me.ch = make(chan struct{})
	}
	return me.ch
}
1028482
func (il *ILertNotifier) sendEvent(event iLertEvent) error {
	body, err := json.Marshal(event)
	if err != nil {
		return err
	}

	res, err := http.Post(apiEndpoint, "application/json", bytes.NewBuffer(body))
	if err != nil {
		return err
	}

	defer res.Body.Close()

	if res.StatusCode != 200 {
		body, _ := ioutil.ReadAll(res.Body)
		return errors.New(fmt.Sprintf("Unexpected HTTP status code: %d (%s)", res.StatusCode, string(body)))
	}

	return nil
}
413736
func Error(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "error", Listener: listener}
}
1354183
func (e EventBuilder) ToEvent(channel, pattern string) Event {
	fields := make([]Field, len(e.fields))
	copy(fields, e.fields)

	return Event{
		fields:  fields,
		kind:    e.kind,
		channel: channel,
		pattern: pattern,
	}
}
98165
func (f *FastHTTPServer) Event(event revel.Event, args interface{}) revel.EventResponse {

	switch event {
	case revel.ENGINE_STARTED:
		signal.Notify(f.signalChan, os.Interrupt, os.Kill)
		go func() {
			_ = <-f.signalChan
			serverLog.Info("Received quit singal Please wait ... ")
			revel.StopServer(nil)
		}()
	case revel.ENGINE_SHUTDOWN_REQUEST:
		if err := f.graceful.Close(); err != nil {
			serverLog.Fatal("Failed to close fasthttp server gracefully, exiting using os.exit", "error", err)
		}
	default:

	}
	return 0
}
13152
func (k *KeyLogger) eventFromBuffer(buffer []byte) (*InputEvent, error) {
	event := &InputEvent{}
	err := binary.Read(bytes.NewBuffer(buffer), binary.LittleEndian, event)
	return event, err
}
724287
func Error(buffer Buffer, event *cue.Event) {
	if event.Error == nil {
		return
	}
	buffer.AppendString(event.Error.Error())
}
349396
func (filterHandler *FilterHandler) Event(logEvent *event.Event) error {
	for _, filterFunc := range filterHandler.filterFuncs {
		if !filterFunc(logEvent) {
			return nil
		}
	}
	return filterHandler.nextHandler.Event(logEvent)
}
1089617
func (c *Client) Event(e *Event) error {
	if c == nil {
		return fmt.Errorf("Client is nil")
	}
	stat, err := e.Encode(c.Tags...)
	if err != nil {
		return err
	}
	return c.sendMsg([]byte(stat))
}
273052
func SendEvent(c Client, e *Event) (*proto.Msg, error) {
	return SendEvents(
		c, &([]Event{*e}),
	)
}
838926
func (_m *APIClient) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
	ret := _m.Called(ctx, options)

	var r0 <-chan events.Message
	if rf, ok := ret.Get(0).(func(context.Context, types.EventsOptions) <-chan events.Message); ok {
		r0 = rf(ctx, options)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(<-chan events.Message)
		}
	}

	var r1 <-chan error
	if rf, ok := ret.Get(1).(func(context.Context, types.EventsOptions) <-chan error); ok {
		r1 = rf(ctx, options)
	} else {
		if ret.Get(1) != nil {
			r1 = ret.Get(1).(<-chan error)
		}
	}

	return r0, r1
}
764600
func (c *containerAdapter) events(ctx context.Context) <-chan events.Message {
	log.G(ctx).Debugf("waiting on events")
	buffer, l := c.backend.SubscribeToEvents(time.Time{}, time.Time{}, c.container.eventFilter())
	eventsq := make(chan events.Message, len(buffer))

	for _, event := range buffer {
		eventsq <- event
	}

	go func() {
		defer c.backend.UnsubscribeFromEvents(l)

		for {
			select {
			case ev := <-l:
				jev, ok := ev.(events.Message)
				if !ok {
					log.G(ctx).Warnf("unexpected event message: %q", ev)
					continue
				}
				select {
				case eventsq <- jev:
				case <-ctx.Done():
					return
				}
			case <-ctx.Done():
				return
			}
		}
	}()

	return eventsq
}
628807
func (r *Runc) Events(context context.Context, id string, interval time.Duration) (chan *Event, error) {
	cmd := r.command(context, "events", fmt.Sprintf("--interval=%ds", int(interval.Seconds())), id)
	rd, err := cmd.StdoutPipe()
	if err != nil {
		return nil, err
	}
	ec, err := Monitor.Start(cmd)
	if err != nil {
		rd.Close()
		return nil, err
	}
	var (
		dec = json.NewDecoder(rd)
		c   = make(chan *Event, 128)
	)
	go func() {
		defer func() {
			close(c)
			rd.Close()
			Monitor.Wait(cmd, ec)
		}()
		for {
			var e Event
			if err := dec.Decode(&e); err != nil {
				if err == io.EOF {
					return
				}
				e = Event{
					Type: "error",
					Err:  err,
				}
			}
			c <- &e
		}
	}()
	return c, nil
}
361953
func (c *SocketConnection) SendEvent(eventHeaders []string) error {
	if len(eventHeaders) <= 0 {
		return fmt.Errorf(ECouldNotSendEvent, len(eventHeaders))
	}

	// lock mutex to prevent event headers from conflicting
	c.mtx.Lock()
	defer c.mtx.Unlock()

	_, err := io.WriteString(c, "sendevent ")
	if err != nil {
		return err
	}

	for _, eventHeader := range eventHeaders {
		_, err := io.WriteString(c, eventHeader)
		if err != nil {
			return err
		}

		_, err = io.WriteString(c, "\r\n")
		if err != nil {
			return err
		}

	}

	_, err = io.WriteString(c, "\r\n")
	if err != nil {
		return err
	}

	return nil
}
562171
func (logger *Logger) SendEvent(logEvent *event.Event) uint64 {
	logEvent.Id = atomic.AddUint64(&logger.lastEventId, 1)

	logger.mutex.RLock()
	for _, eventHandlerSpec := range logger.eventHandlerMap {
		if true { //TODO make dropping configurable per-handler
			select {
			case eventHandlerSpec.eventChannel <- logEvent:
				atomic.StoreUint64(&eventHandlerSpec.lastSentEventId, logEvent.Id)
			default:
				fmt.Fprintf(os.Stderr, "Unable to send event to handler. Buffer full. handler=%s\n", eventHandlerSpec.name)
				//TODO generate an event for this, but put in a time-last-dropped so we don't send the message to the handler which is dropping
				// basically if we are dropping, and we last dropped < X seconds ago, don't generate another "event dropped" message
			}
		} else {
			eventHandlerSpec.eventChannel <- logEvent
			atomic.StoreUint64(&eventHandlerSpec.lastSentEventId, logEvent.Id)
		}
	}
	logger.mutex.RUnlock()

	if logger.GetSync() {
		logger.Sync(logEvent.Id)
	}

	return logEvent.Id
}
918735
func (g *GoHttpServer) Event(event Event, args interface{}) (r EventResponse) {
	switch event {
	case ENGINE_STARTED:
		signal.Notify(g.signalChan, os.Interrupt, os.Kill)
		go func() {
			_ = <-g.signalChan
			serverLogger.Info("Received quit singal Please wait ... ")
			RaiseEvent(ENGINE_SHUTDOWN_REQUEST, nil)
		}()
	case ENGINE_SHUTDOWN_REQUEST:
		ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(Config.IntDefault("app.cancel.timeout", 60)))
		defer cancel()
		g.Server.Shutdown(ctx)
	default:

	}

	return
}