forked from mtusi2026/mtusi2026lab3
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff810a44c1 | ||
|
|
883a2406a7 | ||
|
|
5af170345c |
@@ -170,7 +170,7 @@ func (c *apiClient) waitForReplicas(expected int) error {
|
|||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
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 {
|
func parseFlags() configuration {
|
||||||
@@ -215,7 +215,7 @@ func (c *apiClient) bootstrap() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("login: %w", err)
|
return fmt.Errorf("login: %w", err)
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer func() { _ = response.Body.Close() }()
|
||||||
if response.StatusCode != http.StatusCreated {
|
if response.StatusCode != http.StatusCreated {
|
||||||
return responseError("login", response)
|
return responseError("login", response)
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ func (c *apiClient) createMessage(ctx context.Context, sequence uint64) (string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", 0, err
|
return "", 0, err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer func() { _ = response.Body.Close() }()
|
||||||
_, _ = io.Copy(io.Discard, io.LimitReader(response.Body, 1<<20))
|
_, _ = io.Copy(io.Discard, io.LimitReader(response.Body, 1<<20))
|
||||||
if response.StatusCode != http.StatusCreated {
|
if response.StatusCode != http.StatusCreated {
|
||||||
return response.Header.Get("X-Instance-Id"), response.StatusCode, fmt.Errorf("unexpected status")
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer func() { _ = response.Body.Close() }()
|
||||||
if response.StatusCode != http.StatusOK {
|
if response.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("status %d", response.StatusCode)
|
return nil, fmt.Errorf("status %d", response.StatusCode)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ func writeChart(path string, values []aggregate) error {
|
|||||||
value := maxRPS * float64(step) / 5
|
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="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)
|
||||||
}
|
}
|
||||||
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))
|
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)
|
||||||
for index, replicas := range []int{1, 2, 4} {
|
for index, replicas := range []int{1, 2, 4} {
|
||||||
x := left + plotWidth*float64(index)/2
|
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)
|
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