diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gotosocial/action/server/server.go | 15 | ||||
-rw-r--r-- | cmd/gotosocial/action/testrig/testrig.go | 14 |
2 files changed, 22 insertions, 7 deletions
diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index 8c6cd7afe..8b524d66c 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -63,6 +63,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb" "github.com/superseriousbusiness/gotosocial/internal/gotosocial" "github.com/superseriousbusiness/gotosocial/internal/media" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oidc" "github.com/superseriousbusiness/gotosocial/internal/processing" @@ -70,6 +71,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/transport" "github.com/superseriousbusiness/gotosocial/internal/typeutils" "github.com/superseriousbusiness/gotosocial/internal/web" + "github.com/superseriousbusiness/gotosocial/internal/worker" ) // Start creates and starts a gotosocial server @@ -87,7 +89,14 @@ var Start action.GTSAction = func(ctx context.Context) error { return fmt.Errorf("error creating instance instance: %s", err) } - federatingDB := federatingdb.New(dbService) + // Create the client API and federator worker pools + // NOTE: these MUST NOT be used until they are passed to the + // processor and it is started. The reason being that the processor + // sets the Worker process functions and start the underlying pools + clientWorker := worker.New[messages.FromClientAPI](-1, -1) + fedWorker := worker.New[messages.FromFederator](-1, -1) + + federatingDB := federatingdb.New(dbService, fedWorker) router, err := router.New(ctx, dbService) if err != nil { @@ -138,8 +147,8 @@ var Start action.GTSAction = func(ctx context.Context) error { } // create and start the message processor using the other services we've created so far - processor := processing.NewProcessor(typeConverter, federator, oauthServer, mediaManager, storage, dbService, emailSender) - if err := processor.Start(ctx); err != nil { + processor := processing.NewProcessor(typeConverter, federator, oauthServer, mediaManager, storage, dbService, emailSender, clientWorker, fedWorker) + if err := processor.Start(); err != nil { return fmt.Errorf("error starting processor: %s", err) } diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go index 1e38b5554..010c730a0 100644 --- a/cmd/gotosocial/action/testrig/testrig.go +++ b/cmd/gotosocial/action/testrig/testrig.go @@ -55,8 +55,10 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger" "github.com/superseriousbusiness/gotosocial/internal/api/security" "github.com/superseriousbusiness/gotosocial/internal/gotosocial" + "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/oidc" "github.com/superseriousbusiness/gotosocial/internal/web" + "github.com/superseriousbusiness/gotosocial/internal/worker" "github.com/superseriousbusiness/gotosocial/testrig" ) @@ -71,6 +73,10 @@ var Start action.GTSAction = func(ctx context.Context) error { storageBackend := testrig.NewTestStorage() testrig.StandardStorageSetup(storageBackend, "./testrig/media") + // Create client API and federator worker pools + clientWorker := worker.New[messages.FromClientAPI](-1, -1) + fedWorker := worker.New[messages.FromFederator](-1, -1) + // build backend handlers oauthServer := testrig.NewTestOauthServer(dbService) transportController := testrig.NewTestTransportController(testrig.NewMockHTTPClient(func(req *http.Request) (*http.Response, error) { @@ -79,14 +85,14 @@ var Start action.GTSAction = func(ctx context.Context) error { StatusCode: 200, Body: r, }, nil - }), dbService) + }), dbService, fedWorker) mediaManager := testrig.NewTestMediaManager(dbService, storageBackend) - federator := testrig.NewTestFederator(dbService, transportController, storageBackend, mediaManager) + federator := testrig.NewTestFederator(dbService, transportController, storageBackend, mediaManager, fedWorker) emailSender := testrig.NewEmailSender("./web/template/", nil) - processor := testrig.NewTestProcessor(dbService, storageBackend, federator, emailSender, mediaManager) - if err := processor.Start(ctx); err != nil { + processor := testrig.NewTestProcessor(dbService, storageBackend, federator, emailSender, mediaManager, clientWorker, fedWorker) + if err := processor.Start(); err != nil { return fmt.Errorf("error starting processor: %s", err) } |