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/queue/gcpqueue/queue.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'internal/queue/gcpqueue') diff --git a/internal/queue/gcpqueue/queue.go b/internal/queue/gcpqueue/queue.go index e007bf0f..c4e82465 100644 --- a/internal/queue/gcpqueue/queue.go +++ b/internal/queue/gcpqueue/queue.go @@ -18,7 +18,6 @@ import ( cloudtasks "cloud.google.com/go/cloudtasks/apiv2" taskspb "cloud.google.com/go/cloudtasks/apiv2/cloudtaskspb" - "golang.org/x/pkgsite/internal/config/serverconfig" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/durationpb" @@ -27,27 +26,12 @@ import ( "golang.org/x/pkgsite/internal/config" "golang.org/x/pkgsite/internal/derrors" "golang.org/x/pkgsite/internal/log" - "golang.org/x/pkgsite/internal/middleware" "golang.org/x/pkgsite/internal/queue" ) // New creates a new Queue with name queueName based on the configuration // in cfg. When running locally, Queue uses numWorkers concurrent workers. -func New(ctx context.Context, cfg *config.Config, queueName string, numWorkers int, expGetter middleware.ExperimentGetter, processFunc queue.InMemoryProcessFunc) (queue.Queue, error) { - if !serverconfig.OnGCP() { - experiments, err := expGetter(ctx) - if err != nil { - return nil, err - } - var names []string - for _, e := range experiments { - if e.Rollout > 0 { - names = append(names, e.Name) - } - } - return queue.NewInMemory(ctx, numWorkers, names, processFunc), nil - } - +func New(ctx context.Context, cfg *config.Config, queueName string, numWorkers int) (queue.Queue, error) { client, err := cloudtasks.NewClient(ctx) if err != nil { return nil, err -- cgit v1.3