// renderEvent varies output depending on the information provided
// by the current taskEvent.
330738
func (r *Renderer) RenderEvent(event *TaskEvent) string {
	switch event.Type {
	case "eos":
		return ""
	}

	s := ""

	if r.options.showTime {
		s += fmt.Sprintf("(%s) ", time.Unix(0, event.Time).Format(time.UnixDate))
	}

	if event.Thread != "" {
		s += fmt.Sprintf("[%s] -- ", event.Thread)
	}

	s += fmt.Sprintf("%s", event.Stage)

	if event.Subtask.Name != "" {
		s += " -- "
		if event.Subtask.Total != 0 {
			s += fmt.Sprintf("(%d/%d): ", event.Subtask.Index, event.Subtask.Total)
		}

		s += fmt.Sprintf("%s", event.Subtask.Name)

		if event.Subtask.Progress.Total != 0 {
			s += fmt.Sprintf(" ... %d%%",
				(event.Subtask.Progress.Current/event.Subtask.Progress.Total)*100,
			)
		}
	}

	return s
}
187498
func (m *MonitorFormatter) FormatEvent(pl *payload.Payload) bool {
	switch pl.Type {
	case payload.EventSample:
		m.FormatSample(pl.Data, pl.CPU)
	case payload.RecordLost:
		LostEvent(pl.Lost, pl.CPU)
	default:
		return false
	}

	return true
}
721627
func (c *GorymanClient) SendEvent(e *Event) error {
	epb, err := EventToProtocolBuffer(e)
	if err != nil {
		return err
	}

	message := &proto.Msg{}
	message.Events = append(message.Events, epb)

	_, err = c.sendMaybeRecv(message)
	return err
}
182946
func RenderScript(cfg cloudinit.RenderConfig, ds ...Decorator) ([]byte, error) {
	out, err := cfg.RenderScript()
	if err != nil {
		return nil, err
	}
	return applyDecorators([]byte(out), ds), nil
}
92853
func (i *I) Render(ictx *Context) (string, error) {
	tpl, err := i.template(ictx)
	if err != nil {
		return "", err
	}

	var result bytes.Buffer
	var data interface{}
	if ictx != nil {
		data = ictx.Data
	}
	if err := tpl.Execute(&result, data); err != nil {
		return "", err
	}

	return result.String(), nil
}
1011778
func (p *Parser) handleEvent(rawEvent []string) *event.Event {
	normalizer := normalizer.Parser{}
	if len(rawEvent) == 0 {
		return nil
	}
	firstLine := rawEvent[0]

	// First, try to parse the prefix
	match, suffix, generalMeta := parsePrefix(p.pgPrefixRegex, firstLine)
	if !match {
		// Note: this may be noisy when debug logging is turned on, since the
		// postgres general log contains lots of other statements as well.
		logrus.WithField("line", firstLine).Debug("Log line prefix didn't match expected format")
		return nil
	}

	ev := &event.Event{
		Data: make(map[string]interface{}, 0),
	}

	addFieldsToEvent(generalMeta, ev)

	// Now, parse the slow query header
	match, query, slowQueryMeta := parsePrefix(slowQueryHeaderRegex, suffix)

	if !match {
		logrus.WithField("line", firstLine).Debug("didn't find slow query header, skipping line")
		return nil
	}

	if rawDuration, ok := slowQueryMeta["duration"]; ok {
		duration, _ := strconv.ParseFloat(rawDuration, 64)
		ev.Data["duration"] = duration
	} else {
		logrus.WithField("query", query).Debug("Failed to find query duration in log line")
	}

	// Finally, concatenate the remaining text to form the query, and attempt to
	// normalize it.
	for _, line := range rawEvent[1:] {
		query += " " + strings.TrimLeft(line, " \t")
	}
	normalizedQuery := normalizer.NormalizeQuery(query)

	ev.Data["query"] = query
	ev.Data["normalized_query"] = normalizedQuery
	if len(normalizer.LastTables) > 0 {
		ev.Data["tables"] = strings.Join(normalizer.LastTables, " ")
	}
	if len(normalizer.LastComments) > 0 {
		ev.Data["comments"] = "/* " + strings.Join(normalizer.LastComments, " */ /* ") + " */"
	}

	return ev
}
690736
func Render(c Compo) {
	WhenDebug(func() {
		Logf("rendering %T")
	})

	if err := render(c); err != nil {
		Log(err)
	}
}
1225622
func (c *Controller) RenderText(text string, objs ...interface{}) Result {
	c.setStatusIfNil(http.StatusOK)

	finalText := text
	if len(objs) > 0 {
		finalText = fmt.Sprintf(text, objs...)
	}
	return &RenderTextResult{finalText}
}
94361
func (e *Executor) ProcessEvent(id string, et libcontainerdtypes.EventType, ei libcontainerdtypes.EventInfo) error {
	switch et {
	case libcontainerdtypes.EventExit:
		deleteTaskAndContainer(context.Background(), e.client, id, nil)
		return e.exitHandler.HandleExitEvent(ei.ContainerID)
	}
	return nil
}
73523
func (c *Client) SimpleEvent(title, text string) error {
	e := NewEvent(title, text)
	return c.Event(e)
}
751534
func ControlEvent(v interface{}) *Event {
	event := NewEvent(v)
	event.Control = true
	return event
}
992248
func (c *Context) SSEvent(name string, message interface{}) {
	c.Render(-1, sse.Event{
		Event: name,
		Data:  message,
	})
}
378808
func (c *Controller) RenderTemplate(templatePath string) Result {
	c.setStatusIfNil(http.StatusOK)

	// Get the Template.
	lang, _ := c.ViewArgs[CurrentLocaleViewArg].(string)
	template, err := MainTemplateLoader.TemplateLang(templatePath, lang)
	if err != nil {
		return c.RenderError(err)
	}

	return &RenderTemplateResult{
		Template: template,
		ViewArgs: c.ViewArgs,
	}
}
204084
func (b *batchRenderer) render(startTime float64) {
	// If the batch is empty, mark as unscheduled, and stop render cycle.
	if len(b.batch) == 0 {
		b.scheduled = false
		return
	}

	// Drain the current batch.
	pending := b.batch
	b.batch = nil
	b.idx = make(map[Component]int)

	// Process batch.
	for i, c := range pending {
		// Skip unmounted components.
		if c.Context().unmounted {
			continue
		}

		// Check for remaining time budget, targeting 60fps (~16ms per frame).
		if i > 0 {
			elapsed := global.Get("performance").Call("now").Float() - startTime
			budgetRemaining := (1000 / 60) - elapsed
			avgRenderTime := elapsed / float64(i)
			// If the budget remaining is less than 2 times the average
			// Component render time, push the remainder of the batch to the
			// next frame.
			if budgetRemaining < avgRenderTime*2 {
				b.batch = pending[i:]
				for i, c := range b.batch {
					b.idx[c] = i
				}
				break
			}
		}

		// Perform render.
		prevHTML := extractHTML(c.Context().prevRender)
		nextHTML, skip, pendingMounts := renderComponent(c, c)
		if skip {
			continue
		}
		replaceNode(nextHTML.node, prevHTML.node)
		mount(pendingMounts...)
	}

	// Schedule next frame.
	requestAnimationFrame(b.render)
}
280132
func (e *Eventer) EmitEvent(event *drivers.TaskEvent) error {

	select {
	case <-e.ctx.Done():
		return e.ctx.Err()
	case e.events <- event:
		if e.logger.IsTrace() {
			e.logger.Trace("emitting event", "event", event)
		}
	}
	return nil
}
682421
func (ctx *Context) Render(bytes []byte) {
	//debug
	//fmt.Println("response msg = ", string(bytes))
	ctx.Writer.WriteHeader(200)
	_, err := ctx.Writer.Write(bytes)
	if err != nil {
		panic(err)
	}
}
1223104
func renderChild(w *tabwriter.Writer, wf *wfv1.Workflow, nInfo renderNode, depth int,
	nodePrefix string, childPrefix string, parentFiltered bool,
	childIndex int, maxIndex int, childIndent bool, outFmt string) {
	var part, subp string
	if parentFiltered && childIndent {
		if maxIndex == 0 {
			part = "--"
			subp = "  "
		} else if childIndex == 0 {
			part = "·-"
			subp = "| "
		} else if childIndex == maxIndex {
			part = "└-"
			subp = "  "
		} else {
			part = "├-"
			subp = "| "
		}
	} else if !parentFiltered {
		if childIndex == maxIndex {
			part = "└-"
			subp = "  "
		} else {
			part = "├-"
			subp = "| "
		}
	}
	var childNodePrefix, childChldPrefix string
	if !parentFiltered {
		depth = depth + 1
		childNodePrefix = childPrefix + part
		childChldPrefix = childPrefix + subp
	} else {
		if childIndex == 0 {
			childNodePrefix = nodePrefix + part
		} else {
			childNodePrefix = childPrefix + part
		}
		childChldPrefix = childPrefix + subp
	}
	nInfo.renderNodes(w, wf, depth, childNodePrefix, childChldPrefix, outFmt)
}