Skip to content

Commit bd79330

Browse files
authored
fix(storage): Zero allocation issue with fiber (#1273)
* fix(storage): Zero allocation issue with fiber * ci: Bump Go version
1 parent 0d2a55c commit bd79330

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
- uses: actions/setup-go@v6
2424
with:
25-
go-version: 1.24.1
25+
go-version: 1.24.4
2626
repository: "${{ github.event.inputs.repository || 'TwiN/gatus' }}"
2727
ref: "${{ github.event.inputs.ref || 'master' }}"
2828
- uses: actions/checkout@v5

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
steps:
1919
- uses: actions/setup-go@v6
2020
with:
21-
go-version: 1.24.1
21+
go-version: 1.24.4
2222
- uses: actions/checkout@v5
2323
- name: Build binary to make sure it works
2424
run: go build

api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func (a *API) createRouter(cfg *config.Config) *fiber.App {
5252
},
5353
ReadBufferSize: cfg.Web.ReadBufferSize,
5454
Network: fiber.NetworkTCP,
55+
Immutable: true, // If not enabled, will cause issues due to fiber's zero allocation. See #1268 and https://docs.gofiber.io/#zero-allocation
5556
})
5657
if os.Getenv("ENVIRONMENT") == "dev" {
5758
app.Use(cors.New(cors.Config{

api/external_endpoint.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func CreateExternalEndpointResult(cfg *config.Config) fiber.Handler {
5656
}
5757
result.Duration = parsedDuration
5858
}
59-
if !result.Success && c.Query("error") != "" {
60-
result.Errors = append(result.Errors, c.Query("error"))
59+
if errorFromQuery := c.Query("error"); !result.Success && len(errorFromQuery) > 0 {
60+
result.AddError(errorFromQuery)
6161
}
6262
convertedEndpoint := externalEndpoint.ToEndpoint()
6363
if err := store.Get().InsertEndpointResult(convertedEndpoint, result); err != nil {

config/endpoint/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ func (r *Result) AddError(error string) {
7272
return
7373
}
7474
}
75-
r.Errors = append(r.Errors, error)
75+
r.Errors = append(r.Errors, error+"")
7676
}

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
module github.com/TwiN/gatus/v5
22

3-
go 1.24.1
3+
go 1.24.4
4+
5+
toolchain go1.24.7
46

57
require (
68
code.gitea.io/sdk/gitea v0.21.0
79
github.com/TwiN/deepmerge v0.2.2
810
github.com/TwiN/g8/v2 v2.0.0
9-
github.com/TwiN/gocache/v2 v2.2.2
11+
github.com/TwiN/gocache/v2 v2.4.0
1012
github.com/TwiN/health v1.6.0
1113
github.com/TwiN/logr v0.3.1
1214
github.com/TwiN/whois v1.1.11

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ github.com/TwiN/deepmerge v0.2.2 h1:FUG9QMIYg/j2aQyPPhA3XTFJwXSNHI/swaR4Lbyxwg4=
1212
github.com/TwiN/deepmerge v0.2.2/go.mod h1:4OHvjV3pPNJCJZBHswYAwk6rxiD8h8YZ+9cPo7nu4oI=
1313
github.com/TwiN/g8/v2 v2.0.0 h1:+hwIbRLMhDd2iwHzkZUPp2FkX7yTx8ddYOnS91HkDqQ=
1414
github.com/TwiN/g8/v2 v2.0.0/go.mod h1:4sVAF27q8T8ISggRa/Fb0drw7wpB22B6eWd+/+SGMqE=
15-
github.com/TwiN/gocache/v2 v2.2.2 h1:4HToPfDV8FSbaYO5kkbhLpEllUYse5rAf+hVU/mSsuI=
16-
github.com/TwiN/gocache/v2 v2.2.2/go.mod h1:WfIuwd7GR82/7EfQqEtmLFC3a2vqaKbs4Pe6neB7Gyc=
15+
github.com/TwiN/gocache/v2 v2.4.0 h1:BZ/TqvhipDQE23MFFTjC0MiI1qZ7GEVtSdOFVVXyr18=
16+
github.com/TwiN/gocache/v2 v2.4.0/go.mod h1:Cl1c0qNlQlXzJhTpAARVqpQDSuGDM5RhtzPYAM1x17g=
1717
github.com/TwiN/health v1.6.0 h1:L2ks575JhRgQqWWOfKjw9B0ec172hx7GdToqkYUycQM=
1818
github.com/TwiN/health v1.6.0/go.mod h1:Z6TszwQPMvtSiVx1QMidVRgvVr4KZGfiwqcD7/Z+3iw=
1919
github.com/TwiN/logr v0.3.1 h1:CfTKA83jUmsAoxqrr3p4JxEkqXOBnEE9/f35L5MODy4=

0 commit comments

Comments
 (0)