Changed the sugestions

This commit is contained in:
mjarkk 2019-07-12 15:04:07 +02:00
parent fd4d4a1dc6
commit 63b1d871c5
No known key found for this signature in database
GPG key ID: 147D0BE9258C6C95
3 changed files with 12 additions and 44 deletions

View file

@ -53,9 +53,7 @@ oS:
openCommand: open {{filename}} openCommand: open {{filename}}
openLinkCommand: open {{link}} openLinkCommand: open {{link}}
update: update:
refreshProjectTime: 100ms dockerRefreshInterval: 100ms
refreshContainersAndServicesTime: 100ms
refreshVolumesTime: 100ms
method: never method: never
stats: stats:
graphs: graphs:

View file

@ -191,20 +191,12 @@ type OSConfig struct {
} }
// UpdateConfig determines what the default settings are for updating the ui // 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 { type UpdateConfig struct {
// RefreshProjectTime determines the time betweens updates of the project panel // RefreshProjectTime determines the time betweens updates of all continues docker commands like docker ps, docker images, etc.
RefreshProjectTime string `yaml:"refreshProjectTime,omitempty"` // It expects a valid duration like: 100ms, 2s, 200ns
// for docs see: https://golang.org/pkg/time/#ParseDuration
// RefreshContainersAndServicesTime determines the time betweens updates of the containers and services panel DockerRefreshInterval time.Duration `yaml:"dockerRefreshInterval,omitempty"`
RefreshContainersAndServicesTime string `yaml:"refreshContainersAndServicesTime,omitempty"` Method string `yaml:"method,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 // GraphConfig specifies how to make a graph of recorded container stats
@ -356,10 +348,8 @@ func GetDefaultConfig() UserConfig {
}, },
OS: GetPlatformDefaultConfig(), OS: GetPlatformDefaultConfig(),
Update: UpdateConfig{ Update: UpdateConfig{
RefreshProjectTime: "100ms", DockerRefreshInterval: time.Millisecond * 100,
RefreshContainersAndServicesTime: "100ms", Method: "never",
RefreshVolumesTime: "100ms",
Method: "never",
}, },
Stats: StatsConfig{ Stats: StatsConfig{
MaxDuration: duration, MaxDuration: duration,

View file

@ -267,34 +267,14 @@ func (gui *Gui) Run() error {
gui.waitForIntro.Add(1) gui.waitForIntro.Add(1)
} }
updates := gui.Config.UserConfig.Update dockerRefreshInterval := gui.Config.UserConfig.Update.DockerRefreshInterval
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() { go func() {
gui.waitForIntro.Wait() gui.waitForIntro.Wait()
gui.goEvery(time.Millisecond*50, gui.renderAppStatus) gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
gui.goEvery(time.Millisecond*30, gui.reRenderMain) gui.goEvery(time.Millisecond*30, gui.reRenderMain)
gui.goEvery(projectDuration, gui.refreshProject) gui.goEvery(dockerRefreshInterval, gui.refreshProject)
gui.goEvery(containersAndServicesDuration, gui.refreshContainersAndServices) gui.goEvery(dockerRefreshInterval, gui.refreshContainersAndServices)
gui.goEvery(volumesDuration, gui.refreshVolumes) gui.goEvery(dockerRefreshInterval, gui.refreshVolumes)
gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails) gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails)
gui.goEvery(time.Millisecond*1000, gui.checkForContextChange) gui.goEvery(time.Millisecond*1000, gui.checkForContextChange)
}() }()