diff --git a/go.mod b/go.mod index e209185..50bc920 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,9 @@ replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240702054557-aa55 require ( cdr.dev/slog v1.6.2-0.20240126064726-20367d4aede6 - github.com/benbjohnson/clock v1.3.5 github.com/breml/rootcerts v0.2.11 github.com/coder/coder/v2 v2.10.1-0.20240703121105-f6639b788f7b + github.com/coder/quartz v0.1.0 github.com/fatih/color v1.17.0 github.com/go-chi/chi/v5 v5.1.0 github.com/google/uuid v1.6.0 @@ -61,7 +61,6 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/charmbracelet/lipgloss v0.8.0 // indirect github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 // indirect - github.com/coder/quartz v0.1.0 // indirect github.com/coder/retry v1.5.1 // indirect github.com/coder/serpent v0.7.0 // indirect github.com/coder/terraform-provider-coder v0.23.0 // indirect diff --git a/go.sum b/go.sum index 743f4eb..b6d9cbc 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= -github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E= diff --git a/logger.go b/logger.go index 7d220b0..231d01b 100644 --- a/logger.go +++ b/logger.go @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/benbjohnson/clock" "github.com/fatih/color" "github.com/google/uuid" appsv1 "k8s.io/api/apps/v1" @@ -20,6 +19,7 @@ import ( "cdr.dev/slog" "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/agentsdk" + "github.com/coder/quartz" // *Never* remove this. Certificates are not bundled as part // of the container, so this is necessary for all connections @@ -29,7 +29,7 @@ import ( type podEventLoggerOptions struct { client kubernetes.Interface - clock clock.Clock + clock quartz.Clock coderURL *url.URL logger slog.Logger @@ -49,7 +49,7 @@ func newPodEventLogger(ctx context.Context, opts podEventLoggerOptions) (*podEve opts.logDebounce = 30 * time.Second } if opts.clock == nil { - opts.clock = clock.New() + opts.clock = quartz.NewReal() } logCh := make(chan agentLog, 512) @@ -388,7 +388,7 @@ type agentLog struct { type logQueuer struct { mu sync.Mutex logger slog.Logger - clock clock.Clock + clock quartz.Clock q chan agentLog coderURL *url.URL @@ -525,7 +525,7 @@ func (l *logQueuer) loggerTimeout(agentToken string) { type agentLoggerLifecycle struct { scriptLogger agentsdk.ScriptLogger - closeTimer *clock.Timer + closeTimer *quartz.Timer close func() } diff --git a/logger_test.go b/logger_test.go index 0e09cdf..51d99f5 100644 --- a/logger_test.go +++ b/logger_test.go @@ -11,7 +11,6 @@ import ( "testing" "time" - "github.com/benbjohnson/clock" "github.com/go-chi/chi/v5" "github.com/hashicorp/yamux" "github.com/stretchr/testify/require" @@ -30,6 +29,7 @@ import ( "github.com/coder/coder/v2/codersdk" "github.com/coder/coder/v2/codersdk/agentsdk" "github.com/coder/coder/v2/testutil" + "github.com/coder/quartz" ) func TestReplicaSetEvents(t *testing.T) { @@ -43,7 +43,7 @@ func TestReplicaSetEvents(t *testing.T) { namespace := "test-namespace" client := fake.NewSimpleClientset() - cMock := clock.NewMock() + cMock := quartz.NewMock(t) reporter, err := newPodEventLogger(ctx, podEventLoggerOptions{ client: client, coderURL: agentURL, @@ -140,7 +140,7 @@ func TestPodEvents(t *testing.T) { namespace := "test-namespace" client := fake.NewSimpleClientset() - cMock := clock.NewMock() + cMock := quartz.NewMock(t) reporter, err := newPodEventLogger(ctx, podEventLoggerOptions{ client: client, coderURL: agentURL, @@ -284,7 +284,7 @@ func Test_logQueuer(t *testing.T) { api := newFakeAgentAPI(t) agentURL, err := url.Parse(api.server.URL) require.NoError(t, err) - clock := clock.NewMock() + clock := quartz.NewMock(t) ttl := time.Second ch := make(chan agentLog) @@ -300,7 +300,7 @@ func Test_logQueuer(t *testing.T) { }, } - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() go lq.work(ctx) @@ -335,7 +335,7 @@ func Test_logQueuer(t *testing.T) { logs = testutil.RequireRecvCtx(ctx, t, api.logs) require.Len(t, logs, 1) - clock.Add(2 * ttl) + clock.Advance(ttl) // wait for the client to disconnect _ = testutil.RequireRecvCtx(ctx, t, api.disconnect) }) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy