From d29b966ca794634ccd1758dcd59cd2c8baf23422 Mon Sep 17 00:00:00 2001 From: Jean Barkhuysen Date: Mon, 23 Feb 2026 06:13:17 -0700 Subject: internal/queue: move InMemory queue to its own package Currently, InMemory queue sits in queue, and is instantiated in gcpqueue for convenience. In preparation for a third queue type (Postgres), this CL separates the two more cleanly, making it more ergonomic for the new queue type to slot in next to the existing two. This CL doesn't change any logic: it just exists to make the next CL smaller and easier to review. I also took the liberty of adding some tests specific to the InMemory queue, since I didn't find any. Let me know if it's tested in another place, though, and if you'd prefer me to remove it. Updates golang/go#74027. Change-Id: I44bd92129f33bc7975fcd138c905e0b7ab49d257 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/747881 kokoro-CI: kokoro Auto-Submit: Jonathan Amsterdam LUCI-TryBot-Result: Go LUCI Reviewed-by: Ethan Lee Reviewed-by: Jonathan Amsterdam --- internal/testing/integration/frontend_test.go | 3 ++- internal/testing/integration/worker_test.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'internal/testing/integration') diff --git a/internal/testing/integration/frontend_test.go b/internal/testing/integration/frontend_test.go index e9cbe997..66a6aa6e 100644 --- a/internal/testing/integration/frontend_test.go +++ b/internal/testing/integration/frontend_test.go @@ -25,6 +25,7 @@ import ( "golang.org/x/pkgsite/internal/proxy" "golang.org/x/pkgsite/internal/proxy/proxytest" "golang.org/x/pkgsite/internal/queue" + "golang.org/x/pkgsite/internal/queue/inmemqueue" "golang.org/x/pkgsite/internal/source" "golang.org/x/pkgsite/internal/testing/htmlcheck" ) @@ -89,7 +90,7 @@ func setupQueue(ctx context.Context, t *testing.T, proxyModules []*proxytest.Mod cctx, cancel := context.WithCancel(ctx) proxyClient, teardown := proxytest.SetupTestClient(t, proxyModules) sourceClient := source.NewClient(http.DefaultClient) - q := queue.NewInMemory(cctx, 1, experimentNames, + q := inmemqueue.New(cctx, 1, experimentNames, func(ctx context.Context, mpath, version string) (_ int, err error) { return fetchserver.FetchAndUpdateState(ctx, mpath, version, proxyClient, sourceClient, testDB) }) diff --git a/internal/testing/integration/worker_test.go b/internal/testing/integration/worker_test.go index d6f75766..1edf9620 100644 --- a/internal/testing/integration/worker_test.go +++ b/internal/testing/integration/worker_test.go @@ -22,13 +22,13 @@ import ( "golang.org/x/pkgsite/internal/config" "golang.org/x/pkgsite/internal/index" "golang.org/x/pkgsite/internal/proxy" - "golang.org/x/pkgsite/internal/queue" + "golang.org/x/pkgsite/internal/queue/inmemqueue" "golang.org/x/pkgsite/internal/source" "golang.org/x/pkgsite/internal/worker" ) func setupWorker(ctx context.Context, t *testing.T, proxyClient *proxy.Client, indexClient *index.Client, - redisCacheClient *redis.Client) (*httptest.Server, *worker.Fetcher, *queue.InMemory) { + redisCacheClient *redis.Client) (*httptest.Server, *worker.Fetcher, *inmemqueue.InMemory) { t.Helper() fetcher := &worker.Fetcher{ @@ -39,7 +39,7 @@ func setupWorker(ctx context.Context, t *testing.T, proxyClient *proxy.Client, i } // TODO: it would be better if InMemory made http requests // back to worker, rather than calling fetch itself. - queue := queue.NewInMemory(ctx, 10, nil, func(ctx context.Context, mpath, version string) (int, error) { + queue := inmemqueue.New(ctx, 10, nil, func(ctx context.Context, mpath, version string) (int, error) { code, _, err := fetcher.FetchAndUpdateState(ctx, mpath, version, "test") return code, err }) -- cgit v1.3-5-g9baa