// sendEvent publishes the specified event to the events channel
766937
func (w *filePoller) sendEvent(e fsnotify.Event, chClose <-chan struct{}) error {
	select {
	case w.events <- e:
	case <-chClose:
		return fmt.Errorf("closed")
	}
	return nil
}
1047647
func (s *SubscribeToEventInput) SetEvent(v string) *SubscribeToEventInput {
	s.Event = &v
	return s
}
1013093
func SendEvent(ws *websocket.Conn, event string) error {
	js := fmt.Sprintf("sendEvent('%s');", event)
	err := ws.WriteMessage(websocket.TextMessage, []byte(js))
	if err != nil {
		return err
	}
	status.Status.SendedBytes += len(js)

	return nil
}
785710
func sendRequest(address string, event *common.EventInfo) error {

	client, err := client.NewClient(address)
	if err != nil {
		return err
	}

	return client.SendRequest(event)
}
543280
func (self *FSock) SendEvent(eventSubclass string, eventParams map[string]string) (string, error) {
	return self.SendEventWithBody(eventSubclass, eventParams, "")
}
1203008
func (s *StdoutClient) SendEvents(events map[string]event.Event) error {
	var n int
	var stats = make([]string, 0)

	for _, e := range events {
		for _, stat := range e.Stats() {

			stat = fmt.Sprintf("%s%s", s.prefix, strings.Replace(stat, "%HOST%", Hostname, 1))
			_n := n + len(stat) + 1

			if _n > UDPPayloadSize {
				// with this last event, the UDP payload would be too big
				if _, err := fmt.Fprintf(s.FD, strings.Join(stats, "\n")); err != nil {
					return err
				}
				// reset payload after flushing, and add the last event
				stats = []string{stat}
				n = len(stat)
				continue
			}

			// can fit more into the current payload
			n = _n
			stats = append(stats, stat)
		}
	}

	if len(stats) != 0 {
		if _, err := fmt.Fprintf(s.FD, strings.Join(stats, "\n")); err != nil {
			return err
		}
	}

	return nil
}
315537
func (f EventHandlerFunc) HandleEvent(resp http.ResponseWriter, req *http.Request, event *Event) {
	f(resp, req, event)
}
1044180
func (r *readdcw) send(es []*event) {
	for _, e := range es {
		var syse Event
		if e.e, syse = decode(e.filter, e.action); e.e == 0 && syse == 0 {
			continue
		}
		switch {
		case e.action == syscall.FILE_ACTION_MODIFIED:
			e.ftype = fTypeUnknown
		case e.filter&uint32(dirmarker) != 0:
			e.ftype = fTypeDirectory
		default:
			e.ftype = fTypeFile
		}
		switch {
		case e.e == 0:
			e.e = syse
		case syse != 0:
			r.c <- &event{
				pathw:  e.pathw,
				name:   e.name,
				ftype:  e.ftype,
				action: e.action,
				filter: e.filter,
				e:      syse,
			}
		}
		r.c <- e
	}
}
1243318
func (self *events) AddEvent(e *Event) error {
	self.updateEventStore(e)
	self.watcherLock.RLock()
	defer self.watcherLock.RUnlock()
	watchesToSend := self.findValidWatchers(e)
	for _, watchObject := range watchesToSend {
		watchObject.eventChannel.GetChannel() <- e
	}
	log.Infof("WRIT %s %s", e.EventType, e.EventAction.String())
	return nil
}
1105141
func (e *eventer) Publish(name string, data interface{}) {
	evt := NewEvent(name, data)
	e.in <- evt
}
235388
func (dis *dispatcher) DispatchEvent(event *core.Event) error {
	if event == nil {
		return errors.New("empty event provided")
	}

	for regKey, listeners := range dis.listeners {
		matched, err := regexp.MatchString(regKey, event.Key)
		if err != nil {
			openlogging.GetLogger().Errorf("regular expresssion for key %s failed: %s", regKey, err)
			continue
		}
		if matched {
			for _, listener := range listeners {
				openlogging.GetLogger().Debugf("event generated for %s", regKey)
				go listener.Event(event)
			}
		}
	}

	return nil
}
425275
func (es *eventStream) sendMemberEvent(me serf.MemberEvent) error {
	members := make([]Member, 0, len(me.Members))
	for _, m := range me.Members {
		sm := Member{
			Name:        m.Name,
			Addr:        m.Addr,
			Port:        m.Port,
			Tags:        m.Tags,
			Status:      m.Status.String(),
			ProtocolMin: m.ProtocolMin,
			ProtocolMax: m.ProtocolMax,
			ProtocolCur: m.ProtocolCur,
			DelegateMin: m.DelegateMin,
			DelegateMax: m.DelegateMax,
			DelegateCur: m.DelegateCur,
		}
		members = append(members, sm)
	}

	header := responseHeader{
		Seq:   es.seq,
		Error: "",
	}
	rec := memberEventRecord{
		Event:   me.String(),
		Members: members,
	}
	return es.client.Send(&header, &rec)
}
710960
func (c *DefaultPublisher) PublishDeviceEvent(appID string, devID string, eventType types.EventType, payload interface{}) error {
	key := DeviceKey{appID, devID, DeviceEvents, string(eventType)}
	msg, err := json.Marshal(payload)
	if err != nil {
		return fmt.Errorf("Unable to marshal the message payload: %s", err)
	}
	c.publish(key.String(), msg, time.Now())
	return nil
}
187048
func (ms *MetricSender) Send(ev events.Event) error {
	return ms.eventEmitter.Emit(ev)
}
327313
func (s *EventSubscription) SetEvent(v string) *EventSubscription {
	s.Event = &v
	return s
}
966644
func sendEvents(evtChan chan *dt.ScheduledEvent, interval time.Duration) {
	t := time.NewTicker(time.Minute)
	select {
	case now := <-t.C:
		sendEventsTick(evtChan, now)
		sendEvents(evtChan, interval)
	}
}
620285
func (c *Client) SendRequest(event *common.EventInfo) error {

	httpc := http.Client{
		Transport: &http.Transport{
			DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
				return net.DialUnix("unix", nil, c.addr)
			},
		},
	}

	b := new(bytes.Buffer)
	if err := json.NewEncoder(b).Encode(event); err != nil {
		return fmt.Errorf("Unable to encode message: %s", err)
	}

	resp, err := httpc.Post("http://unix", "application/json", b)
	if err != nil {
		return err
	}

	if resp.StatusCode == http.StatusAccepted {
		return nil
	}

	errorBuffer, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return fmt.Errorf("Invalid request: %s", err)
	}

	return fmt.Errorf("Invalid request : %s", string(errorBuffer))
}