// return the resulting lrp of the given event, that is the lrp being created
// or the lrp in the new lrp in a ActualLRPChanged event.  Returns nil for
// crashed and removed events.  Returns true iff this is a crashed event.
333354
func getEventLRP(e models.Event) (*models.ActualLRP, bool) {
	switch x := e.(type) {
	case *models.ActualLRPCreatedEvent:
		lrp, _, _ := x.ActualLrpGroup.Resolve()
		return lrp, false
	case *models.ActualLRPChangedEvent:
		lrp, _, _ := x.After.Resolve()
		return lrp, false
	case *models.ActualLRPInstanceCreatedEvent:
		return x.ActualLrp, false
	case *models.ActualLRPInstanceChangedEvent:
		return x.After.ToActualLRP(x.ActualLRPKey, x.ActualLRPInstanceKey), false
	case *models.ActualLRPCrashedEvent:
		return nil, true
	}

	return nil, false
}
420895
func (s *IssuesService) GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	event := new(IssueEvent)
	resp, err := s.client.Do(ctx, req, event)
	if err != nil {
		return nil, resp, err
	}

	return event, resp, nil
}
1213540
func EventRegisterDefaultImpl() error {
	var err C.virError
	if i := int(C.virEventRegisterDefaultImplWrapper(&err)); i != 0 {
		return makeError(&err)
	}
	return nil
}
1103256
func (c *syncClient) Lpop(arg0 string) (result []byte, err Error) {
	arg0bytes := []byte(arg0)

	var resp Response
	resp, err = c.conn.ServiceRequest(&LPOP, [][]byte{arg0bytes})
	if err == nil {
		result = resp.GetBulkData()
	}
	return result, err

}
288865
func (el *EndpointsLock) RecordEvent(s string) {
	if el.LockConfig.EventRecorder == nil {
		return
	}
	events := fmt.Sprintf("%v %v", el.LockConfig.Identity, s)
	el.LockConfig.EventRecorder.Eventf(&v1.Endpoints{ObjectMeta: el.e.ObjectMeta}, v1.EventTypeNormal, "LeaderElection", events)
}
203648
func (w *Webhook) HasReleaseEvent() bool {
	return w.SendEverything ||
		(w.ChooseEvents && w.HookEvents.Release)
}
648840
func (c *convergence) orphanedActualLRPs(logger lager.Logger) {
	logger = logger.Session("orphaned-actual-lrps")

	rows, err := c.selectOrphanedActualLRPs(logger, c.db)
	if err != nil {
		logger.Error("failed-query", err)
		return
	}

	c.keysToRetire = append(c.keysToRetire, scanActualLRPs(logger, rows)...)
}
1265598
func (e *eventLogger) lastEventObservationFromCache(key string) eventLog {
	value, ok := e.cache.Get(key)
	if ok {
		observationValue, ok := value.(eventLog)
		if ok {
			return observationValue
		}
	}
	return eventLog{}
}
1120544
func (p *RowsQueryEventParser) Parse(raw *RawV4Event) (Event, error) {
	query := &RowsQueryEvent{
		Event: raw,
	}

	data := raw.VariableLengthData()
	if len(data) < 1 {
		return raw, errors.Newf("Invalid message length")
	}

	query.truncatedQuery = data[1:]

	return query, nil
}
996952
func checkIfEventSatisfiesRequest(request *Request, event *Event) bool {
	startTime := request.StartTime
	endTime := request.EndTime
	eventTime := event.Timestamp
	if !startTime.IsZero() {
		if startTime.After(eventTime) {
			return false
		}
	}
	if !endTime.IsZero() {
		if endTime.Before(eventTime) {
			return false
		}
	}
	if !request.EventType[event.EventType] {
		return false
	}
	return true
}
1098838
func (n *cachedNode) rlp() []byte {
	if node, ok := n.node.(rawNode); ok {
		return node
	}
	blob, err := rlp.EncodeToBytes(n.node)
	if err != nil {
		panic(err)
	}
	return blob
}
1133485
func eventLoop(ctx context.Context, config Config, eventDecoder encoding.Decoder) (err error) {
	for err == nil {
		select {
		case <-ctx.Done():
			err = ctx.Err()
			return
		default:
		}

		var e scheduler.Event
		if err = eventDecoder.Decode(&e); err != nil {
			return
		}

		err = config.handler.HandleEvent(ctx, &e)
	}
	return
}
850407
func (g *gossipRegistry) eventLoop() {
	for {
		select {
		// return when done
		case <-g.done:
			return
		case ev := <-g.events:
			// TODO: nonblocking update
			g.Lock()
			if _, ok := g.members[ev.node]; ok {
				g.members[ev.node] = ev.action
			}
			g.Unlock()
		}
	}
}
1321165
func (c *RPCClient) UserEvent(name string, payload []byte, coalesce bool) error {
	header := requestHeader{
		Command: eventCommand,
		Seq:     c.getSeq(),
	}
	req := eventRequest{
		Name:     name,
		Payload:  payload,
		Coalesce: coalesce,
	}
	return c.genericRPC(&header, &req, nil)
}
48176
func Result(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "result", Listener: listener}
}
794112
func (p *QueryEventParser) Parse(raw *RawV4Event) (Event, error) {
	query := &QueryEvent{
		Event: raw,
	}

	type fixedBodyStruct struct {
		ThreadId           uint32
		Duration           uint32
		DatabaseNameLength uint8
		ErrorCode          uint16
		StatusLength       uint16
	}

	fixed := fixedBodyStruct{}

	_, err := readLittleEndian(raw.FixedLengthData(), &fixed)
	if err != nil {
		return raw, errors.Wrap(err, "Failed to read fixed body")
	}

	query.threadId = fixed.ThreadId
	query.duration = fixed.Duration
	query.errorCode = mysql_proto.ErrorCode_Type(fixed.ErrorCode)

	data := raw.VariableLengthData()

	dbNameEnd := int(fixed.StatusLength) + int(fixed.DatabaseNameLength)
	if dbNameEnd+1 > len(data) {
		return raw, errors.Newf("Invalid message length")
	}

	query.statusBytes = data[:fixed.StatusLength]

	query.databaseName = data[fixed.StatusLength:dbNameEnd]

	query.query = data[dbNameEnd+1:]

	err = p.parseStatus(query)
	if err != nil {
		return raw, err
	}

	return query, nil
}
1248021
func ValidateEvent(eventCategory EventCategory, event Event) bool {
	valid := false
	switch eventCategory {
	case EventCategoryDefined:
		valid = int(event) >= 0 && event < EventDefinedLast
	case EventCategoryUndefined:
		valid = int(event) >= 0 && event < EventUndefinedLast
	case EventCategoryStarted:
		valid = int(event) >= 0 && event < EventStartedLast
	case EventCategorySuspended:
		valid = int(event) >= 0 && event < EventSuspendedLast
	case EventCategoryResumed:
		valid = int(event) >= 0 && event < EventResumedLast
	case EventCategoryStopped:
		valid = int(event) >= 0 && event < EventStoppedLast
	case EventCategoryShutdown:
		valid = int(event) >= 0 && event < EventShutdownLast
	case EventCategoryPmsuspended:
		valid = int(event) >= 0 && event < EventPMSuspendedLast
	}

	return valid
}