From 39426cf77deb1c32b4131f01f7d8863325cc51fe Mon Sep 17 00:00:00 2001 From: Disco Date: Sat, 7 May 2022 00:13:25 +0100 Subject: [PATCH] Comment updates (#11) * removed unused code * comment update --- omnivore/omnivore.go | 12 +++++++++++- omnivore/ssh.go | 17 ----------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/omnivore/omnivore.go b/omnivore/omnivore.go index 4dd5444..97ac851 100644 --- a/omnivore/omnivore.go +++ b/omnivore/omnivore.go @@ -25,7 +25,17 @@ type OmniCommandFlags struct { func Run(cmd *OmniCommandFlags) { ui.MakeDP() - // Used to avoid race condition in UI initialisation. + /* + Used to avoid race condition in UI initialisation. + + Essentially, we need to populate the ossh StreamCycle before starting the UI due to pointer logic. Additionally, + once the UI is started, it can be cumbersome to process single line errors when closing the app, so if anything + goes wrong with the job initialisation, we can just print a failure without needing to handle any UI closures. + + safeToStartUI should indicate that StreamCycle was successfully populated. + + uiStarted should indicate when the UI is functional, so we can start refreshing it. + */ safeToStartUI := make(chan struct{}, 1) uiStarted := make(chan struct{}, 1) diff --git a/omnivore/ssh.go b/omnivore/ssh.go index 39ec8ab..5eb8897 100644 --- a/omnivore/ssh.go +++ b/omnivore/ssh.go @@ -138,20 +138,3 @@ func readStreamWithTimeout(res massh.Result, t time.Duration, grp *group.ValueGr } } } - -// Read Stdout stream -func readStream(res massh.Result, grp *group.ValueGrouping, wg *sync.WaitGroup) { - for { - select { - case d := <-res.StdOutStream: - grp.AddToGroup(group.NewIdentifyingPair(res.Host, d)) - case e := <-res.StdErrStream: - grp.AddToGroup(group.NewIdentifyingPair(res.Host, e)) - case <-res.DoneChannel: - // Confirm that the remote command has finished. - ui.DP.StreamCycle.AddCompletedHost(res.Host) - wg.Done() - return - } - } -}