event

package
v0.0.0-...-ba096a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Processing and type definitions for events within moebot. These should eventually make their way into the database to keep track of events in moebot

Index

Constants

View Source
const (
	// Timer marker key for the total time elapsed in the timer
	TimerMarkTotal = "_total"
	// Timer marker key for the first event in the timer. This will always be present
	TimerMarkStart = "_start"
	// Timer marker key for the last event in the timer. This will always be present
	TimerMarkEnd = "_end"
	// Timer marker keys for commands
	TimerMarkCommandBegin = "command_begin_"
	TimerMarkCommandEnd   = "command_end_"
	// Timer marker keys for db interactions
	TimerMarkDbBegin = "db_begin_"
	TimerMarkDbEnd   = "db_end_"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

type Timer struct {
	Marks []TimerMark
}

func StartNamedTimer

func StartNamedTimer(firstName string) Timer

Creates a new Timer object with an initial "Start" time. As soon as you call this the timer will start

func StartTimer

func StartTimer() Timer

Creates a new timer with the default name

func (*Timer) AddMark

func (t *Timer) AddMark(name string)

Adds a single mark with a name. This should be called like the following:

func main() {
	t := StartNamedTimer()
	t.AddMark("Processing Names")
	processNames()
	t.StopTimer()
}

This will give you a marker for "Processing Names" that was the total time processNames took

func (*Timer) StopTimer

func (t *Timer) StopTimer() map[string]time.Duration

Stops this timer, returning back a map of names to durations.

type TimerMark

type TimerMark struct {
	Duration time.Duration `json:"d"` // Duration between this mark and the next one. Will not be populated until the timer is stopped
	Name     string        `json:"n"` // Name of the marker
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL