From c113c1e960313b77010acb17d3aa5e9799b4a364 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Fri, 20 Dec 2024 14:48:51 -0600 Subject: [PATCH] gobwebs bump and updates for custom worker pool size per queue --- cmd/api/main.go | 1 + cmd/global.go | 15 +++++++++++++++ cmd/links/main.go | 1 + cmd/list/main.go | 1 + cmd/short/main.go | 1 + go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 4b3a7b7..85ec98f 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -124,6 +124,7 @@ func run() error { WithEmail(sq). WithStorage(storesvc). DefaultMiddlewareWithConfig(mwConf). + SetWorkerPoolFunc(cmd.GetWorkerPoolCount). WithQueues(eq, wq). WithMiddleware( database.Middleware(db), diff --git a/cmd/global.go b/cmd/global.go index b0da51b..f788bc5 100644 --- a/cmd/global.go +++ b/cmd/global.go @@ -6,6 +6,7 @@ import ( "path/filepath" "testing" + work "git.sr.ht/~sircmpwn/dowork" "petersanchez.com/x/migrate" ) @@ -41,3 +42,17 @@ func RunMigrations(t *testing.T, db *sql.DB) { t.Fatalf("Migrate() err = %v; want nil", err) } } + +// GetWorkerPoolCount will return the size of the worker pool based on the queue name +func GetWorkerPoolCount(queue *work.Queue) int { + var pSize int + switch queue.Name() { + case "general": + pSize = 10 + case "invoice": + pSize = 3 + default: + pSize = 5 + } + return pSize +} diff --git a/cmd/links/main.go b/cmd/links/main.go index 2a23479..57bc96d 100644 --- a/cmd/links/main.go +++ b/cmd/links/main.go @@ -215,6 +215,7 @@ func run() error { WithEmail(sq). WithStorage(storesvc). DefaultMiddlewareWithConfig(mwConf). + SetWorkerPoolFunc(cmd.GetWorkerPoolCount). WithQueues(eq, wq, wqi). WithMiddleware( database.Middleware(db), diff --git a/cmd/list/main.go b/cmd/list/main.go index 7bd3d3b..dc78a1c 100644 --- a/cmd/list/main.go +++ b/cmd/list/main.go @@ -86,6 +86,7 @@ func run() error { Initialize(). WithAppInfo("links-list", Version). DefaultMiddlewareWithConfig(mwConf). + SetWorkerPoolFunc(cmd.GetWorkerPoolCount). WithQueues(eq, wq). WithMiddleware( database.Middleware(db), diff --git a/cmd/short/main.go b/cmd/short/main.go index 3d5217e..34bf3e2 100644 --- a/cmd/short/main.go +++ b/cmd/short/main.go @@ -84,6 +84,7 @@ func run() error { Initialize(). WithAppInfo("links-short", Version). DefaultMiddlewareWithConfig(mwConf). + SetWorkerPoolFunc(cmd.GetWorkerPoolCount). WithQueues(eq, wq). WithMiddleware( database.Middleware(db), diff --git a/go.mod b/go.mod index 098a5ac..4d10843 100644 --- a/go.mod +++ b/go.mod @@ -28,11 +28,11 @@ require ( golang.org/x/text v0.20.0 golang.org/x/time v0.5.0 hg.code.netlandish.com/~netlandish/sendygo v0.0.0-20230124192435-bbf347776232 - netlandish.com/x/gobwebs v0.0.0-20241219173153-b82c01404952 - netlandish.com/x/gobwebs-formguard v0.0.0-20240917220134-4b6f2ec7d1f5 + netlandish.com/x/gobwebs v0.0.0-20241220204303-8cc27ccc6753 + netlandish.com/x/gobwebs-formguard v0.0.0-20241220204736-317383081170 netlandish.com/x/gobwebs-graphql v0.0.0-20241126234432-2cc59b2f7ebd - netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c - netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d + netlandish.com/x/gobwebs-oauth2 v0.0.0-20241220204404-89f1f20efe41 + netlandish.com/x/gobwebs-ses-feedback v0.0.0-20241220204650-1fb58398640c petersanchez.com/x/carrier v0.2.2 petersanchez.com/x/carrier/ses v0.0.0-20240905233033-4a4ffeb71da4 petersanchez.com/x/carrier/smtp v0.0.0-20240905233033-4a4ffeb71da4 diff --git a/go.sum b/go.sum index f8c65f1..697b30b 100644 --- a/go.sum +++ b/go.sum @@ -2584,16 +2584,16 @@ modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfp modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA= modernc.org/z v1.2.20/go.mod h1:zU9FiF4PbHdOTUxw+IF8j7ArBMRPsHgq10uVPt6xTzo= modernc.org/zappy v1.0.0/go.mod h1:hHe+oGahLVII/aTTyWK/b53VDHMAGCBYYeZ9sn83HC4= -netlandish.com/x/gobwebs v0.0.0-20241219173153-b82c01404952 h1:DtzTNLe5MtlYVZuOT0zANWFddsRzM1np4FuMkA/Y0tU= -netlandish.com/x/gobwebs v0.0.0-20241219173153-b82c01404952/go.mod h1:Q/e3xSbcMqYMpYS360pz5gAA0/cCRrBxNHnCAYODHoA= -netlandish.com/x/gobwebs-formguard v0.0.0-20240917220134-4b6f2ec7d1f5 h1:z5hzVB0R+k2+bh8yuM7XeojGesI2i5tnQHrBNzxG2Xw= -netlandish.com/x/gobwebs-formguard v0.0.0-20240917220134-4b6f2ec7d1f5/go.mod h1:mmpJMveuFlwAj3URXlNmVox3WYCn4OVlozFQdd95wH8= +netlandish.com/x/gobwebs v0.0.0-20241220204303-8cc27ccc6753 h1:3htAHoDxML3oPrWUqUwB/xTNCwqKKs6Zmsd724EOTik= +netlandish.com/x/gobwebs v0.0.0-20241220204303-8cc27ccc6753/go.mod h1:Q/e3xSbcMqYMpYS360pz5gAA0/cCRrBxNHnCAYODHoA= +netlandish.com/x/gobwebs-formguard v0.0.0-20241220204736-317383081170 h1:iv47dRbi7yc1h2NhXVpescloOI+Bae/hqBNb1uw8jW4= +netlandish.com/x/gobwebs-formguard v0.0.0-20241220204736-317383081170/go.mod h1:t89MBCex25e8eHB4WlyXac/ss+8qJ2oZN8rCapYGBXQ= netlandish.com/x/gobwebs-graphql v0.0.0-20241126234432-2cc59b2f7ebd h1:QJzQj/+2XAEHM0mCxqYleV0sVM2tNZBS6zP6uuOB+Tk= netlandish.com/x/gobwebs-graphql v0.0.0-20241126234432-2cc59b2f7ebd/go.mod h1:HLqiAsZAamUcGy6bF8Vyt0eGXX2UhSl8oO1Z/vUoDlM= -netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c h1:OiR7uZB8Ix33d6uZcNucqWC53XQlJLqH5MyskIaFD20= -netlandish.com/x/gobwebs-oauth2 v0.0.0-20240216010400-f0f42e2e3a7c/go.mod h1:YFuvoy5GEi60A+UfPZyC87DTAwFLrvUldZL6dr+ks1o= -netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d h1:Qof6jqwfFMcmw08Qh5UocDsqjNIvpsZwZuxGqhbh8GE= -netlandish.com/x/gobwebs-ses-feedback v0.0.0-20231224192331-d90c2b73e55d/go.mod h1:Sa3HY6qxvpiXAdQsBnMYPGNRO2OPYzxx+XwgfP6WrNc= +netlandish.com/x/gobwebs-oauth2 v0.0.0-20241220204404-89f1f20efe41 h1:SNhpXQS5kVQUMi4E3VdwJLq0uAdW/Q8VsU/F3WrkL7w= +netlandish.com/x/gobwebs-oauth2 v0.0.0-20241220204404-89f1f20efe41/go.mod h1:+AvlXsp4pIwzB92VWGMdtjUi5T5m7DMjthXOtp6obbY= +netlandish.com/x/gobwebs-ses-feedback v0.0.0-20241220204650-1fb58398640c h1:H/w1cGcFPOG0IgrdPbs19VfRnPM02JMgPEqQbeDfNh0= +netlandish.com/x/gobwebs-ses-feedback v0.0.0-20241220204650-1fb58398640c/go.mod h1:PQChMxEOJN17mcA392hgMf8zPtg7LI8nOkMqCkwYUaM= petersanchez.com/x/carrier v0.2.2 h1:BVi4OAwQeVOw7lu9cSxoYmI/m0UEhfdXn3I8fGSVAd8= petersanchez.com/x/carrier v0.2.2/go.mod h1:/9rUr2uuk8PlvhB5EtbCI64JzA8lTHoeeiapmDuVGKU= petersanchez.com/x/carrier/ses v0.0.0-20240905233033-4a4ffeb71da4 h1:D4J3TzqpLoSMaiQeKqltWFphkUIke/rgpZZMJ3ghGhs= -- 2.45.2