forked from mtusi2026/mtusi2026lab3
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92e3d58548 | ||
|
|
05248a98ce | ||
|
|
16d97cf481 |
@@ -170,7 +170,7 @@ func (c *apiClient) waitForReplicas(expected int) error {
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
return fmt.Errorf("nginx discovered %d of %d API replicas: %w", len(instances), expected, ctx.Err())
|
||||
return fmt.Errorf("Nginx discovered %d of %d API replicas: %w", len(instances), expected, ctx.Err())
|
||||
}
|
||||
|
||||
func parseFlags() configuration {
|
||||
@@ -215,7 +215,7 @@ func (c *apiClient) bootstrap() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("login: %w", err)
|
||||
}
|
||||
defer func() { _ = response.Body.Close() }()
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusCreated {
|
||||
return responseError("login", response)
|
||||
}
|
||||
@@ -284,7 +284,7 @@ func (c *apiClient) createMessage(ctx context.Context, sequence uint64) (string,
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
defer func() { _ = response.Body.Close() }()
|
||||
defer response.Body.Close()
|
||||
_, _ = io.Copy(io.Discard, io.LimitReader(response.Body, 1<<20))
|
||||
if response.StatusCode != http.StatusCreated {
|
||||
return response.Header.Get("X-Instance-Id"), response.StatusCode, fmt.Errorf("unexpected status")
|
||||
@@ -383,7 +383,7 @@ func scrapeMetrics(endpoint string) (map[string]float64, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() { _ = response.Body.Close() }()
|
||||
defer response.Body.Close()
|
||||
if response.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("status %d", response.StatusCode)
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func writeChart(path string, values []aggregate) error {
|
||||
value := maxRPS * float64(step) / 5
|
||||
fmt.Fprintf(&output, `<line class="grid" x1="%g" y1="%g" x2="%g" y2="%g"/><text x="%g" y="%g" text-anchor="end" font-size="12">%.0f</text>`, left, y, left+plotWidth, y, left-10, y+4, value)
|
||||
}
|
||||
fmt.Fprintf(&output, `<line class="axis" x1="%g" y1="%g" x2="%g" y2="%g"/><line class="axis" x1="%g" y1="%g" x2="%g" y2="%g"/>`, left, top, left, top+plotHeight, left, top+plotHeight, left+plotWidth, top+plotHeight)
|
||||
output.WriteString(fmt.Sprintf(`<line class="axis" x1="%g" y1="%g" x2="%g" y2="%g"/><line class="axis" x1="%g" y1="%g" x2="%g" y2="%g"/>`, left, top, left, top+plotHeight, left, top+plotHeight, left+plotWidth, top+plotHeight))
|
||||
for index, replicas := range []int{1, 2, 4} {
|
||||
x := left + plotWidth*float64(index)/2
|
||||
fmt.Fprintf(&output, `<text x="%g" y="%g" text-anchor="middle" font-size="13">%d</text>`, x, top+plotHeight+25, replicas)
|
||||
|
||||
Reference in New Issue
Block a user