refresh rate config property renaming
This commit is contained in:
parent
da26ba8165
commit
5a90d141ab
|
@ -13,7 +13,7 @@ type Component struct {
|
|||
Title string
|
||||
Location config.Location
|
||||
Size config.Size
|
||||
RefreshRateMs int
|
||||
RateMs int
|
||||
}
|
||||
|
||||
func NewComponent(dbl ui.Drawable, cmr *data.Consumer, cfg config.ComponentConfig) *Component {
|
||||
|
@ -24,7 +24,7 @@ func NewComponent(dbl ui.Drawable, cmr *data.Consumer, cfg config.ComponentConfi
|
|||
Title: cfg.Title,
|
||||
Location: cfg.GetLocation(),
|
||||
Size: cfg.GetSize(),
|
||||
RefreshRateMs: *cfg.RefreshRateMs,
|
||||
RateMs: *cfg.RateMs,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -18,7 +18,7 @@ const (
|
|||
|
||||
type ComponentConfig struct {
|
||||
Title string `yaml:"title"`
|
||||
RefreshRateMs *int `yaml:"refresh-rate-ms,omitempty"`
|
||||
RateMs *int `yaml:"rate-ms,omitempty"`
|
||||
Position [][]int `yaml:"position,flow"`
|
||||
Triggers []TriggerConfig `yaml:"triggers,omitempty"`
|
||||
Type ComponentType `yaml:",omitempty"`
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
defaultRefreshRateMs = 1000
|
||||
defaultRateMs = 1000
|
||||
defaultScale = 1
|
||||
defaultTheme = console.ThemeDark
|
||||
)
|
||||
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
2
main.go
2
main.go
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue