mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 13:47:29 -06:00
[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:
parent
24cec4e7aa
commit
baf933cb9f
130 changed files with 1037 additions and 1083 deletions
|
|
@ -41,7 +41,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
|
|||
}
|
||||
|
||||
// validate + fetch target account
|
||||
targetAccount, err := p.db.GetAccountByID(ctx, form.AccountID)
|
||||
targetAccount, err := p.state.DB.GetAccountByID(ctx, form.AccountID)
|
||||
if err != nil {
|
||||
if errors.Is(err, db.ErrNoEntries) {
|
||||
err = fmt.Errorf("account with ID %s does not exist", form.AccountID)
|
||||
|
|
@ -52,7 +52,7 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
|
|||
}
|
||||
|
||||
// fetch statuses by IDs given in the report form (noop if no statuses given)
|
||||
statuses, err := p.db.GetStatuses(ctx, form.StatusIDs)
|
||||
statuses, err := p.state.DB.GetStatuses(ctx, form.StatusIDs)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("db error fetching report target statuses: %w", err)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
|
|
@ -79,11 +79,11 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
|
|||
Forwarded: &form.Forward,
|
||||
}
|
||||
|
||||
if err := p.db.PutReport(ctx, report); err != nil {
|
||||
if err := p.state.DB.PutReport(ctx, report); err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
p.clientWorker.Queue(messages.FromClientAPI{
|
||||
p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
|
||||
APObjectType: ap.ObjectProfile,
|
||||
APActivityType: ap.ActivityFlag,
|
||||
GTSModel: report,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import (
|
|||
|
||||
// Get returns the user view of a moderation report, with the given id.
|
||||
func (p *Processor) Get(ctx context.Context, account *gtsmodel.Account, id string) (*apimodel.Report, gtserror.WithCode) {
|
||||
report, err := p.db.GetReportByID(ctx, id)
|
||||
report, err := p.state.DB.GetReportByID(ctx, id)
|
||||
if err != nil {
|
||||
if err == db.ErrNoEntries {
|
||||
return nil, gtserror.NewErrorNotFound(err)
|
||||
|
|
@ -64,7 +64,7 @@ func (p *Processor) GetMultiple(
|
|||
minID string,
|
||||
limit int,
|
||||
) (*apimodel.PageableResponse, gtserror.WithCode) {
|
||||
reports, err := p.db.GetReports(ctx, resolved, account.ID, targetAccountID, maxID, sinceID, minID, limit)
|
||||
reports, err := p.state.DB.GetReports(ctx, resolved, account.ID, targetAccountID, maxID, sinceID, minID, limit)
|
||||
if err != nil {
|
||||
if err == db.ErrNoEntries {
|
||||
return util.EmptyPageableResponse(), nil
|
||||
|
|
|
|||
|
|
@ -19,22 +19,18 @@
|
|||
package report
|
||||
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/concurrency"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
)
|
||||
|
||||
type Processor struct {
|
||||
db db.DB
|
||||
tc typeutils.TypeConverter
|
||||
clientWorker *concurrency.WorkerPool[messages.FromClientAPI]
|
||||
state *state.State
|
||||
tc typeutils.TypeConverter
|
||||
}
|
||||
|
||||
func New(db db.DB, tc typeutils.TypeConverter, clientWorker *concurrency.WorkerPool[messages.FromClientAPI]) Processor {
|
||||
func New(state *state.State, tc typeutils.TypeConverter) Processor {
|
||||
return Processor{
|
||||
tc: tc,
|
||||
db: db,
|
||||
clientWorker: clientWorker,
|
||||
state: state,
|
||||
tc: tc,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue