From fd4d4a1dc6d74832c8fa4d6512f11e3f5cb1fde7 Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 12 Jul 2019 10:26:59 +0200 Subject: [PATCH 1/4] Made the information pulling time dynamic --- docs/Config.md | 5 ++++- pkg/config/app_config.go | 25 +++++++++++++++++++------ pkg/gui/gui.go | 27 ++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 27b33440..bcd2a670 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -13,7 +13,7 @@ Changes to the user config will only take place after closing and re-opening laz ## Default: -``` +```yml gui: scrollHeight: 2 theme: @@ -53,6 +53,9 @@ oS: openCommand: open {{filename}} openLinkCommand: open {{link}} update: + refreshProjectTime: 100ms + refreshContainersAndServicesTime: 100ms + refreshVolumesTime: 100ms method: never stats: graphs: diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 79ed97d0..de444661 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -53,8 +53,7 @@ type UserConfig struct { // OS determines what defaults are set for opening files and links OS OSConfig `yaml:"oS,omitempty"` - // Update is currently not being used, but like lazydocker, it may be used down - // the line to help you update automatically. + // UpdateConfig determines what the default settings are for updating the ui Update UpdateConfig `yaml:"update,omitempty"` // Stats determines how long lazydocker will gather container stats for, and @@ -191,10 +190,21 @@ type OSConfig struct { OpenLinkCommand string `yaml:"openLinkCommand,omitempty"` } -// UpdateConfig is currently not being used, but may be used down the line to -// allow for automatic updates +// UpdateConfig determines what the default settings are for updating the ui +// +// For the RefreshProjectTime, RefreshContainersAndServicesTime and RefreshVolumesTime +// the application expects a valid duration like: 100ms, 2s, 200ns +// for docs see: https://golang.org/pkg/time/#ParseDuration type UpdateConfig struct { - Method string `yaml:"method,omitempty"` + // RefreshProjectTime determines the time betweens updates of the project panel + RefreshProjectTime string `yaml:"refreshProjectTime,omitempty"` + + // RefreshContainersAndServicesTime determines the time betweens updates of the containers and services panel + RefreshContainersAndServicesTime string `yaml:"refreshContainersAndServicesTime,omitempty"` + + // RefreshVolumesTime determines the time betweens updates of the volumes panel + RefreshVolumesTime string `yaml:"refreshVolumesTime,omitempty"` + Method string `yaml:"method,omitempty"` } // GraphConfig specifies how to make a graph of recorded container stats @@ -346,7 +356,10 @@ func GetDefaultConfig() UserConfig { }, OS: GetPlatformDefaultConfig(), Update: UpdateConfig{ - Method: "never", + RefreshProjectTime: "100ms", + RefreshContainersAndServicesTime: "100ms", + RefreshVolumesTime: "100ms", + Method: "never", }, Stats: StatsConfig{ MaxDuration: duration, diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 8ef53626..0e3127ea 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -267,13 +267,34 @@ func (gui *Gui) Run() error { gui.waitForIntro.Add(1) } + updates := gui.Config.UserConfig.Update + projectDuration := time.Millisecond * 100 + containersAndServicesDuration := time.Millisecond * 100 + volumesDuration := time.Millisecond * 100 + toBind := []struct { + BindTo *time.Duration + Value string + }{ + {&projectDuration, updates.RefreshProjectTime}, + {&containersAndServicesDuration, updates.RefreshContainersAndServicesTime}, + {&volumesDuration, updates.RefreshVolumesTime}, + } + for _, item := range toBind { + duration, err := time.ParseDuration(item.Value) + if err == nil { + *item.BindTo = duration + continue + } + gui.Log.Error("Can't parse duration:", err) + } + go func() { gui.waitForIntro.Wait() gui.goEvery(time.Millisecond*50, gui.renderAppStatus) gui.goEvery(time.Millisecond*30, gui.reRenderMain) - gui.goEvery(time.Millisecond*100, gui.refreshProject) - gui.goEvery(time.Millisecond*100, gui.refreshContainersAndServices) - gui.goEvery(time.Millisecond*100, gui.refreshVolumes) + gui.goEvery(projectDuration, gui.refreshProject) + gui.goEvery(containersAndServicesDuration, gui.refreshContainersAndServices) + gui.goEvery(volumesDuration, gui.refreshVolumes) gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails) gui.goEvery(time.Millisecond*1000, gui.checkForContextChange) }() From 63b1d871c5fe3e0c9fb008f7222109e30380f9ee Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 12 Jul 2019 15:04:07 +0200 Subject: [PATCH 2/4] Changed the sugestions --- docs/Config.md | 4 +--- pkg/config/app_config.go | 24 +++++++----------------- pkg/gui/gui.go | 28 ++++------------------------ 3 files changed, 12 insertions(+), 44 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index bcd2a670..16c053ec 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -53,9 +53,7 @@ oS: openCommand: open {{filename}} openLinkCommand: open {{link}} update: - refreshProjectTime: 100ms - refreshContainersAndServicesTime: 100ms - refreshVolumesTime: 100ms + dockerRefreshInterval: 100ms method: never stats: graphs: diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index de444661..ffb1451b 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -191,20 +191,12 @@ type OSConfig struct { } // UpdateConfig determines what the default settings are for updating the ui -// -// For the RefreshProjectTime, RefreshContainersAndServicesTime and RefreshVolumesTime -// the application expects a valid duration like: 100ms, 2s, 200ns -// for docs see: https://golang.org/pkg/time/#ParseDuration type UpdateConfig struct { - // RefreshProjectTime determines the time betweens updates of the project panel - RefreshProjectTime string `yaml:"refreshProjectTime,omitempty"` - - // RefreshContainersAndServicesTime determines the time betweens updates of the containers and services panel - RefreshContainersAndServicesTime string `yaml:"refreshContainersAndServicesTime,omitempty"` - - // RefreshVolumesTime determines the time betweens updates of the volumes panel - RefreshVolumesTime string `yaml:"refreshVolumesTime,omitempty"` - Method string `yaml:"method,omitempty"` + // RefreshProjectTime determines the time betweens updates of all continues docker commands like docker ps, docker images, etc. + // It expects a valid duration like: 100ms, 2s, 200ns + // for docs see: https://golang.org/pkg/time/#ParseDuration + DockerRefreshInterval time.Duration `yaml:"dockerRefreshInterval,omitempty"` + Method string `yaml:"method,omitempty"` } // GraphConfig specifies how to make a graph of recorded container stats @@ -356,10 +348,8 @@ func GetDefaultConfig() UserConfig { }, OS: GetPlatformDefaultConfig(), Update: UpdateConfig{ - RefreshProjectTime: "100ms", - RefreshContainersAndServicesTime: "100ms", - RefreshVolumesTime: "100ms", - Method: "never", + DockerRefreshInterval: time.Millisecond * 100, + Method: "never", }, Stats: StatsConfig{ MaxDuration: duration, diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 0e3127ea..1eaaa7c7 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -267,34 +267,14 @@ func (gui *Gui) Run() error { gui.waitForIntro.Add(1) } - updates := gui.Config.UserConfig.Update - projectDuration := time.Millisecond * 100 - containersAndServicesDuration := time.Millisecond * 100 - volumesDuration := time.Millisecond * 100 - toBind := []struct { - BindTo *time.Duration - Value string - }{ - {&projectDuration, updates.RefreshProjectTime}, - {&containersAndServicesDuration, updates.RefreshContainersAndServicesTime}, - {&volumesDuration, updates.RefreshVolumesTime}, - } - for _, item := range toBind { - duration, err := time.ParseDuration(item.Value) - if err == nil { - *item.BindTo = duration - continue - } - gui.Log.Error("Can't parse duration:", err) - } - + dockerRefreshInterval := gui.Config.UserConfig.Update.DockerRefreshInterval go func() { gui.waitForIntro.Wait() gui.goEvery(time.Millisecond*50, gui.renderAppStatus) gui.goEvery(time.Millisecond*30, gui.reRenderMain) - gui.goEvery(projectDuration, gui.refreshProject) - gui.goEvery(containersAndServicesDuration, gui.refreshContainersAndServices) - gui.goEvery(volumesDuration, gui.refreshVolumes) + gui.goEvery(dockerRefreshInterval, gui.refreshProject) + gui.goEvery(dockerRefreshInterval, gui.refreshContainersAndServices) + gui.goEvery(dockerRefreshInterval, gui.refreshVolumes) gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails) gui.goEvery(time.Millisecond*1000, gui.checkForContextChange) }() From 625c4a50845813863694f27e42d0f29dea85124b Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 12 Jul 2019 15:05:30 +0200 Subject: [PATCH 3/4] Updated the config.md --- docs/Config.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/Config.md b/docs/Config.md index 16c053ec..c67562f5 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -54,7 +54,6 @@ oS: openLinkCommand: open {{link}} update: dockerRefreshInterval: 100ms - method: never stats: graphs: - caption: CPU (%) From 5b3cdcd0aa6ab447a15334c4df744c8a8774a84f Mon Sep 17 00:00:00 2001 From: mjarkk Date: Fri, 26 Jul 2019 16:06:46 +0200 Subject: [PATCH 4/4] Fixed sugestion from jesse --- pkg/config/app_config.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index ffb1451b..b02eee2f 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -196,7 +196,6 @@ type UpdateConfig struct { // It expects a valid duration like: 100ms, 2s, 200ns // for docs see: https://golang.org/pkg/time/#ParseDuration DockerRefreshInterval time.Duration `yaml:"dockerRefreshInterval,omitempty"` - Method string `yaml:"method,omitempty"` } // GraphConfig specifies how to make a graph of recorded container stats @@ -349,7 +348,6 @@ func GetDefaultConfig() UserConfig { OS: GetPlatformDefaultConfig(), Update: UpdateConfig{ DockerRefreshInterval: time.Millisecond * 100, - Method: "never", }, Stats: StatsConfig{ MaxDuration: duration,