[chore] move client/federator workerpools to Workers{} (#1575)

* replace concurrency worker pools with base models in State.Workers, update code and tests accordingly

* improve code comment

* change back testrig default log level

* un-comment-out TestAnnounceTwice() and fix

---------

Signed-off-by: kim <grufwub@gmail.com>
Reviewed-by: tobi
This commit is contained in:
kim
2023-03-01 18:26:53 +00:00
committed by GitHub
parent 24cec4e7aa
commit baf933cb9f
130 changed files with 1037 additions and 1083 deletions

View File

@ -20,13 +20,34 @@ package testrig
import (
"bytes"
"context"
"io"
"mime/multipart"
"net/url"
"os"
"time"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/state"
)
func StartWorkers(state *state.State) {
state.Workers.EnqueueClientAPI = func(context.Context, messages.FromClientAPI) {}
state.Workers.EnqueueFederator = func(context.Context, messages.FromFederator) {}
_ = state.Workers.Scheduler.Start(nil)
_ = state.Workers.ClientAPI.Start(1, 10)
_ = state.Workers.Federator.Start(1, 10)
_ = state.Workers.Media.Start(1, 10)
}
func StopWorkers(state *state.State) {
_ = state.Workers.Scheduler.Stop()
_ = state.Workers.ClientAPI.Stop()
_ = state.Workers.Federator.Stop()
_ = state.Workers.Media.Stop()
}
// CreateMultipartFormData is a handy function for taking a fieldname and a filename, and creating a multipart form bytes buffer
// with the file contents set in the given fieldname. The extraFields param can be used to add extra FormFields to the request, as necessary.
// The returned bytes.Buffer b can be used like so: