Skip to content

Commit

Permalink
improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiAw committed Apr 12, 2023
1 parent f851339 commit 64ebf40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
32 changes: 16 additions & 16 deletions client/client.go
Expand Up @@ -19,6 +19,21 @@ type Client struct {
DispatcherServer string `json:"-"`
}

func (c *Client) Ping() error {
rq, err := http.NewRequest("GET", c.DispatcherServer+"/ping", nil)
if err != nil {
return err
}
do, err := c.Do(rq)
if err != nil {
return err
}
if do.StatusCode == http.StatusOK {
return nil
}
return errors.New("error in pinging")
}

func (c *Client) GetCamp() CampAPI {
//get request to dispatcher server /camp

Expand Down Expand Up @@ -102,8 +117,8 @@ func (c *Client) ListenAndDo(ChangedDataChan chan CampAPI, logChan chan string)
stopchan <- true
}
prevCmp = cmp
time.Sleep(2 * time.Second)
}
time.Sleep(500 * time.Millisecond)
}
}

Expand Down Expand Up @@ -134,18 +149,3 @@ func (c *Client) Start() {
}()
wg.Wait()
}

func (c *Client) Ping() error {
rq, err := http.NewRequest("GET", c.DispatcherServer+"/ping", nil)
if err != nil {
return err
}
do, err := c.Do(rq)
if err != nil {
return err
}
if do.StatusCode == http.StatusOK {
return nil
}
return errors.New("error in pinging")
}
2 changes: 1 addition & 1 deletion client/leader.go
Expand Up @@ -103,7 +103,7 @@ func (l *Leader) ListenChangeView(changedDataChan chan CampAPI, logChan chan str
logChan <- message
prevCamp = camp
}
time.Sleep(2 * time.Second)
time.Sleep(500 * time.Millisecond)
}
}

Expand Down
1 change: 0 additions & 1 deletion client/soldierView.go
Expand Up @@ -192,7 +192,6 @@ func StartSoldierView(changedDataChan chan CampAPI, logChan chan string) {
v.addLog(log)
v.Render()
}()
default:
}
}
}

0 comments on commit 64ebf40

Please sign in to comment.