From b82c01404952d5850c69c896b6af7d011a1dc202 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Thu, 19 Dec 2024 11:31:53 -0600 Subject: [PATCH] Final worker size for new dowork version. Also dowork bump --- go.mod | 2 +- go.sum | 4 ++-- server/server.go | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 99d5206..0299bc7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module netlandish.com/x/gobwebs go 1.20 require ( - git.sr.ht/~sircmpwn/dowork v0.0.0-20241216125407-2b00aa42322c + git.sr.ht/~sircmpwn/dowork v0.0.0-20241219115748-a3928eb084db github.com/Masterminds/squirrel v1.5.4 github.com/alexedwards/argon2id v1.0.0 github.com/alexedwards/scs/postgresstore v0.0.0-20240316134038-7e11d57e8885 diff --git a/go.sum b/go.sum index 9730143..fafabb1 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.sr.ht/~sircmpwn/dowork v0.0.0-20241216125407-2b00aa42322c h1:v2opuaN0C5ZpuCifRNR9ZQ8V9IG+Ja80otK1MFj5RnI= -git.sr.ht/~sircmpwn/dowork v0.0.0-20241216125407-2b00aa42322c/go.mod h1:8neHEO3503w/rNtttnR0JFpQgM/GFhaafVwvkPsFIDw= +git.sr.ht/~sircmpwn/dowork v0.0.0-20241219115748-a3928eb084db h1:NX+qg2ZkefnAWL1TvdgumYBggN2f2zYGYQJxIaqaQ5s= +git.sr.ht/~sircmpwn/dowork v0.0.0-20241219115748-a3928eb084db/go.mod h1:8neHEO3503w/rNtttnR0JFpQgM/GFhaafVwvkPsFIDw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= diff --git a/server/server.go b/server/server.go index 4ad750d..12d7838 100644 --- a/server/server.go +++ b/server/server.go @@ -473,7 +473,15 @@ func (s *Server) WithQueues(queues ...*work.Queue) *Server { for _, queue := range queues { ctx, cancel := context.WithCancel(context.Background()) s.queuecan[queue.Name()] = cancel - queue.Start(ctx) + qSize := int(queue.Size() / 10) // Random, just take 10% of size for worker pool + // For now this is probably fine. We should work in a way for this to be configurable + // per queue. + if qSize < 1 { + qSize = 1 + } else if qSize > 5 { + qSize = 5 + } + queue.Start(ctx, qSize) } return s } -- 2.45.2