refresh rate config property renaming

This commit is contained in:
sqshq 2019-04-07 11:17:28 -04:00
parent da26ba8165
commit 5a90d141ab
8 changed files with 48 additions and 48 deletions

View File

@ -9,22 +9,22 @@ import (
type Component struct {
ui.Drawable
*data.Consumer
Type config.ComponentType
Title string
Location config.Location
Size config.Size
RefreshRateMs int
Type config.ComponentType
Title string
Location config.Location
Size config.Size
RateMs int
}
func NewComponent(dbl ui.Drawable, cmr *data.Consumer, cfg config.ComponentConfig) *Component {
return &Component{
Drawable: dbl,
Consumer: cmr,
Type: cfg.Type,
Title: cfg.Title,
Location: cfg.GetLocation(),
Size: cfg.GetSize(),
RefreshRateMs: *cfg.RefreshRateMs,
Drawable: dbl,
Consumer: cmr,
Type: cfg.Type,
Title: cfg.Title,
Location: cfg.GetLocation(),
Size: cfg.GetSize(),
RateMs: *cfg.RateMs,
}
}

View File

@ -85,7 +85,7 @@ func NewRunChart(c config.RunChartConfig, palette console.Palette) *RunChart {
Block: component.NewBlock(c.Title, true, palette),
Consumer: data.NewConsumer(),
lines: []TimeLine{},
timescale: calculateTimescale(*c.RefreshRateMs),
timescale: calculateTimescale(*c.RateMs),
mutex: &sync.Mutex{},
scale: *c.Scale,
mode: ModeDefault,
@ -367,9 +367,9 @@ func getMidRangeTime(r TimeRange) time.Time {
}
// time duration between grid lines
func calculateTimescale(refreshRateMs int) time.Duration {
func calculateTimescale(rateMs int) time.Duration {
multiplier := refreshRateMs * xAxisGridWidth / 2
multiplier := rateMs * xAxisGridWidth / 2
timescale := time.Duration(time.Millisecond * time.Duration(multiplier)).Round(time.Second)
if timescale.Seconds() == 0 {

View File

@ -32,7 +32,7 @@ runcharts:
sample: mongo --quiet --host=localhost blog --eval "db.getCollection('posts').find({status:'INACTIVE'}).itcount()"
barcharts:
- title: EVENTS BY STATUS
refresh-rate-ms: 1000
rate-ms: 1000
position: [[0, 17], [27, 12]]
scale: 0
items:

View File

@ -17,11 +17,11 @@ const (
)
type ComponentConfig struct {
Title string `yaml:"title"`
RefreshRateMs *int `yaml:"refresh-rate-ms,omitempty"`
Position [][]int `yaml:"position,flow"`
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
Type ComponentType `yaml:",omitempty"`
Title string `yaml:"title"`
RateMs *int `yaml:"rate-ms,omitempty"`
Position [][]int `yaml:"position,flow"`
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
Type ComponentType `yaml:",omitempty"`
}
func (c *ComponentConfig) GetLocation() Location {

View File

@ -5,9 +5,9 @@ import (
)
const (
defaultRefreshRateMs = 1000
defaultScale = 1
defaultTheme = console.ThemeDark
defaultRateMs = 1000
defaultScale = 1
defaultTheme = console.ThemeDark
)
func (c *Config) setDefaults() {
@ -28,9 +28,9 @@ func (c *Config) setDefaultValues() {
setDefaultTriggersValues(chart.Triggers)
chart.ComponentConfig.Type = TypeRunChart
if chart.RefreshRateMs == nil {
r := defaultRefreshRateMs
chart.RefreshRateMs = &r
if chart.RateMs == nil {
r := defaultRateMs
chart.RateMs = &r
}
if chart.Scale == nil {
p := defaultScale
@ -49,9 +49,9 @@ func (c *Config) setDefaultValues() {
line.ComponentConfig.Type = TypeSparkLine
line.Item.Label = &line.Title
if line.RefreshRateMs == nil {
r := defaultRefreshRateMs
line.RefreshRateMs = &r
if line.RateMs == nil {
r := defaultRateMs
line.RateMs = &r
}
if line.Scale == nil {
p := defaultScale
@ -65,9 +65,9 @@ func (c *Config) setDefaultValues() {
setDefaultTriggersValues(chart.Triggers)
chart.ComponentConfig.Type = TypeBarChart
if chart.RefreshRateMs == nil {
r := defaultRefreshRateMs
chart.RefreshRateMs = &r
if chart.RateMs == nil {
r := defaultRateMs
chart.RateMs = &r
}
if chart.Scale == nil {
p := defaultScale
@ -81,9 +81,9 @@ func (c *Config) setDefaultValues() {
setDefaultTriggersValues(g.Triggers)
g.ComponentConfig.Type = TypeGauge
if g.RefreshRateMs == nil {
r := defaultRefreshRateMs
g.RefreshRateMs = &r
if g.RateMs == nil {
r := defaultRateMs
g.RateMs = &r
}
if g.Scale == nil {
p := defaultScale
@ -106,9 +106,9 @@ func (c *Config) setDefaultValues() {
setDefaultTriggersValues(box.Triggers)
box.ComponentConfig.Type = TypeAsciiBox
if box.RefreshRateMs == nil {
r := defaultRefreshRateMs
box.RefreshRateMs = &r
if box.RateMs == nil {
r := defaultRateMs
box.RateMs = &r
}
if box.Label == nil {
label := string(i)

View File

@ -18,7 +18,7 @@ type Item struct {
InitScript *string
TransformScript *string
Color *ui.Color
RefreshRateMs int
RateMs int
InteractiveShell *InteractiveShell
}
@ -29,7 +29,7 @@ type InteractiveShell struct {
Cmd *exec.Cmd
}
func NewItems(cfgs []config.Item, refreshRateMs int) []*Item {
func NewItems(cfgs []config.Item, rateMs int) []*Item {
items := make([]*Item, 0)
@ -40,7 +40,7 @@ func NewItems(cfgs []config.Item, refreshRateMs int) []*Item {
InitScript: i.InitScript,
TransformScript: i.TransformScript,
Color: i.Color,
RefreshRateMs: refreshRateMs,
RateMs: rateMs,
}
items = append(items, item)
}
@ -136,7 +136,7 @@ func (i *Item) executeInteractiveShellCmd(variables []string) (string, error) {
timeout := make(chan bool, 1)
go func() {
time.Sleep(time.Duration(i.RefreshRateMs))
time.Sleep(time.Duration(i.RateMs))
timeout <- true
}()

View File

@ -84,15 +84,15 @@ func (h *Handler) handleExit() {
func calcMinRenderRate(layout *layout.Layout) time.Duration {
minRefreshRateMs := layout.Components[0].RefreshRateMs
minRateMs := layout.Components[0].RateMs
for _, c := range layout.Components {
if c.RefreshRateMs < minRefreshRateMs {
minRefreshRateMs = c.RefreshRateMs
if c.RateMs < minRateMs {
minRateMs = c.RateMs
}
}
renderRate := time.Duration(
int(float64(minRefreshRateMs)*refreshRateToRenderRateRatio)) * time.Millisecond
int(float64(minRateMs)*refreshRateToRenderRateRatio)) * time.Millisecond
if renderRate < console.MinRenderInterval {
return console.MinRenderInterval

View File

@ -25,7 +25,7 @@ type Starter struct {
func (s *Starter) start(drawable ui.Drawable, consumer *data.Consumer, componentConfig config.ComponentConfig, itemsConfig []config.Item, triggersConfig []config.TriggerConfig) {
cpt := component.NewComponent(drawable, consumer, componentConfig)
triggers := data.NewTriggers(triggersConfig, consumer, s.opt, s.player)
data.NewSampler(consumer, data.NewItems(itemsConfig, *componentConfig.RefreshRateMs), triggers, s.opt, *componentConfig.RefreshRateMs)
data.NewSampler(consumer, data.NewItems(itemsConfig, *componentConfig.RateMs), triggers, s.opt, *componentConfig.RateMs)
s.lout.AddComponent(cpt)
}