sampler-fork/main.go

40 lines
914 B
Go
Raw Normal View History

2019-01-28 23:09:52 +00:00
package main
import (
2019-02-02 14:45:53 +00:00
"github.com/sqshq/sampler/config"
"github.com/sqshq/sampler/console"
"github.com/sqshq/sampler/data"
"github.com/sqshq/sampler/event"
"github.com/sqshq/sampler/widgets"
2019-01-28 23:09:52 +00:00
ui "github.com/sqshq/termui"
"time"
)
func main() {
2019-02-02 14:45:53 +00:00
cfg := config.Load("/Users/sqshq/Go/src/github.com/sqshq/sampler/config.yml")
csl := console.Console{}
csl.Init()
defer csl.Close()
2019-01-28 23:09:52 +00:00
layout := widgets.NewLayout(ui.TerminalDimensions())
2019-01-30 00:21:57 +00:00
2019-01-31 01:41:51 +00:00
for _, chartConfig := range cfg.RunCharts {
2019-01-28 23:09:52 +00:00
2019-01-31 01:41:51 +00:00
chart := widgets.NewRunChart(chartConfig.Title)
layout.AddComponent(chart, chartConfig.Position, chartConfig.Size, widgets.TypeRunChart)
2019-01-28 23:09:52 +00:00
2019-01-31 23:40:05 +00:00
for _, item := range chartConfig.Items {
2019-02-03 04:11:26 +00:00
data.NewSampler(chart, item, chartConfig.RefreshRateMs)
2019-01-28 23:09:52 +00:00
}
2019-01-31 00:02:38 +00:00
}
handler := event.Handler{
Layout: layout,
RenderEvents: time.NewTicker(console.RenderRate).C,
ConsoleEvents: ui.PollEvents(),
2019-01-28 23:09:52 +00:00
}
handler.HandleEvents()
2019-01-28 23:09:52 +00:00
}