From 06268d865cb31a26404863a1bdef5e272d23dc04 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Wed, 30 Oct 2024 20:57:03 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20refactor=20TCP=20request=20handling?= =?UTF-8?q?=20to=20use=20'URI'=20instead=20of=20'URL'=20for=20con=E2=80=A6?= =?UTF-8?q?=20(#1076)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ refactor TCP request handling to use 'URI' instead of 'URL' for consistency * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- apps/checker/handlers/tcp.go | 14 +++++++------- apps/checker/request/request.go | 2 +- apps/web/src/app/api/checker/test/tcp/route.ts | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/checker/handlers/tcp.go b/apps/checker/handlers/tcp.go index 670d75ee..e51409bf 100644 --- a/apps/checker/handlers/tcp.go +++ b/apps/checker/handlers/tcp.go @@ -99,7 +99,7 @@ func (h Handler) TCPHandler(c *gin.Context) { op := func() error { called++ - res, err := checker.PingTcp(int(req.Timeout), req.URL) + res, err := checker.PingTcp(int(req.Timeout), req.URI) if err != nil { return fmt.Errorf("unable to check tcp %s", err) @@ -107,7 +107,7 @@ func (h Handler) TCPHandler(c *gin.Context) { timingAsString, err := json.Marshal(res) if err != nil { - return fmt.Errorf("error while parsing timing data %s: %w", req.URL, err) + return fmt.Errorf("error while parsing timing data %s: %w", req.URI, err) } latency := res.TCPDone - res.TCPStart @@ -123,7 +123,7 @@ func (h Handler) TCPHandler(c *gin.Context) { Latency: latency, CronTimestamp: req.CronTimestamp, Trigger: trigger, - URI: req.URL, + URI: req.URI, } response = TCPResponse{ @@ -191,7 +191,7 @@ func (h Handler) TCPHandler(c *gin.Context) { MonitorID: monitorId, Error: 1, Trigger: trigger, - URI: req.URL, + URI: req.URI, }, dataSourceName); err != nil { log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird") } @@ -254,7 +254,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) { op := func() error { called++ timestamp := time.Now().UTC().UnixMilli() - res, err := checker.PingTcp(int(req.Timeout), req.URL) + res, err := checker.PingTcp(int(req.Timeout), req.URI) if err != nil { return fmt.Errorf("unable to check tcp %s", err) @@ -272,7 +272,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) { timingAsString, err := json.Marshal(res) if err != nil { - return fmt.Errorf("error while parsing timing data %s: %w", req.URL, err) + return fmt.Errorf("error while parsing timing data %s: %w", req.URI, err) } latency := res.TCPDone - res.TCPStart @@ -287,7 +287,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) { Latency: latency, RequestId: req.RequestId, Trigger: "api", - URI: req.URL, + URI: req.URI, } if req.RequestId != 0 { diff --git a/apps/checker/request/request.go b/apps/checker/request/request.go index 4b145f2a..a940d2a5 100644 --- a/apps/checker/request/request.go +++ b/apps/checker/request/request.go @@ -66,7 +66,7 @@ type HttpCheckerRequest struct { type TCPCheckerRequest struct { Status string `json:"status"` WorkspaceID string `json:"workspaceId"` - URL string `json:"url"` + URI string `json:"uri"` MonitorID string `json:"monitorId"` Trigger string `json:"trigger,omitempty"` RawAssertions []json.RawMessage `json:"assertions,omitempty"` diff --git a/apps/web/src/app/api/checker/test/tcp/route.ts b/apps/web/src/app/api/checker/test/tcp/route.ts index 56d7004e..9c4032a3 100644 --- a/apps/web/src/app/api/checker/test/tcp/route.ts +++ b/apps/web/src/app/api/checker/test/tcp/route.ts @@ -49,7 +49,7 @@ async function checkTCP(url: string, region: MonitorFlyRegion) { }, method: "POST", body: JSON.stringify({ - url, + uri: url, }), next: { revalidate: 0 }, }); -- 2.51.2