[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
commit baf933cb9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
130 changed files with 1037 additions and 1083 deletions

View file

@ -39,7 +39,7 @@ const allowedPinnedCount = 10
// - Status is public, unlisted, or followers-only.
// - Status is not a boost.
func (p *Processor) getPinnableStatus(ctx context.Context, targetStatusID string, requestingAccountID string) (*gtsmodel.Status, gtserror.WithCode) {
targetStatus, err := p.db.GetStatusByID(ctx, targetStatusID)
targetStatus, err := p.state.DB.GetStatusByID(ctx, targetStatusID)
if err != nil {
err = fmt.Errorf("error fetching status %s: %w", targetStatusID, err)
return nil, gtserror.NewErrorNotFound(err)
@ -84,7 +84,7 @@ func (p *Processor) PinCreate(ctx context.Context, requestingAccount *gtsmodel.A
return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
}
pinnedCount, err := p.db.CountAccountPinned(ctx, requestingAccount.ID)
pinnedCount, err := p.state.DB.CountAccountPinned(ctx, requestingAccount.ID)
if err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("error checking number of pinned statuses: %w", err))
}
@ -95,7 +95,7 @@ func (p *Processor) PinCreate(ctx context.Context, requestingAccount *gtsmodel.A
}
targetStatus.PinnedAt = time.Now()
if err := p.db.UpdateStatus(ctx, targetStatus, "pinned_at"); err != nil {
if err := p.state.DB.UpdateStatus(ctx, targetStatus, "pinned_at"); err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error pinning status: %w", err))
}
@ -126,7 +126,7 @@ func (p *Processor) PinRemove(ctx context.Context, requestingAccount *gtsmodel.A
if targetStatus.PinnedAt.IsZero() {
targetStatus.PinnedAt = time.Time{}
if err := p.db.UpdateStatus(ctx, targetStatus, "pinned_at"); err != nil {
if err := p.state.DB.UpdateStatus(ctx, targetStatus, "pinned_at"); err != nil {
return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error unpinning status: %w", err))
}
}