mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 14:52:26 -05: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
|
|
@ -84,8 +84,8 @@ func (p *Processor) OutboxGet(ctx context.Context, requestedUsername string, pag
|
|||
|
||||
// scenario 2 -- get the requested page
|
||||
// limit pages to 30 entries per page
|
||||
publicStatuses, err := p.db.GetAccountStatuses(ctx, requestedAccount.ID, 30, true, true, maxID, minID, false, true)
|
||||
if err != nil && err != db.ErrNoEntries {
|
||||
publicStatuses, err := p.state.DB.GetAccountStatuses(ctx, requestedAccount.ID, 30, true, true, maxID, minID, false, true)
|
||||
if err != nil && !errors.Is(err, db.ErrNoEntries) {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ func (p *Processor) FeaturedCollectionGet(ctx context.Context, requestedUsername
|
|||
return nil, errWithCode
|
||||
}
|
||||
|
||||
statuses, err := p.db.GetAccountPinnedStatuses(ctx, requestedAccount.ID)
|
||||
statuses, err := p.state.DB.GetAccountPinnedStatuses(ctx, requestedAccount.ID)
|
||||
if err != nil {
|
||||
if !errors.Is(err, db.ErrNoEntries) {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
func (p *Processor) authenticate(ctx context.Context, requestedUsername string) (requestedAccount, requestingAccount *gtsmodel.Account, errWithCode gtserror.WithCode) {
|
||||
requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
requestedAccount, err := p.state.DB.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
if err != nil {
|
||||
errWithCode = gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))
|
||||
return
|
||||
|
|
@ -46,7 +46,7 @@ func (p *Processor) authenticate(ctx context.Context, requestedUsername string)
|
|||
return
|
||||
}
|
||||
|
||||
blocked, err := p.db.IsBlocked(ctx, requestedAccount.ID, requestingAccount.ID, true)
|
||||
blocked, err := p.state.DB.IsBlocked(ctx, requestedAccount.ID, requestingAccount.ID, true)
|
||||
if err != nil {
|
||||
errWithCode = gtserror.NewErrorInternalError(err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func (p *Processor) EmojiGet(ctx context.Context, requestedEmojiID string) (inte
|
|||
return nil, errWithCode
|
||||
}
|
||||
|
||||
requestedEmoji, err := p.db.GetEmojiByID(ctx, requestedEmojiID)
|
||||
requestedEmoji, err := p.state.DB.GetEmojiByID(ctx, requestedEmojiID)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting emoji with id %s: %s", requestedEmojiID, err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,25 +19,25 @@
|
|||
package fedi
|
||||
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/visibility"
|
||||
)
|
||||
|
||||
type Processor struct {
|
||||
db db.DB
|
||||
state *state.State
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
filter visibility.Filter
|
||||
}
|
||||
|
||||
// New returns a new fedi processor.
|
||||
func New(db db.DB, tc typeutils.TypeConverter, federator federation.Federator) Processor {
|
||||
func New(state *state.State, tc typeutils.TypeConverter, federator federation.Federator) Processor {
|
||||
return Processor{
|
||||
db: db,
|
||||
state: state,
|
||||
federator: federator,
|
||||
tc: tc,
|
||||
filter: visibility.NewFilter(db),
|
||||
filter: visibility.NewFilter(state.DB),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ func (p *Processor) StatusGet(ctx context.Context, requestedUsername string, req
|
|||
return nil, errWithCode
|
||||
}
|
||||
|
||||
status, err := p.db.GetStatusByID(ctx, requestedStatusID)
|
||||
status, err := p.state.DB.GetStatusByID(ctx, requestedStatusID)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorNotFound(err)
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ func (p *Processor) StatusRepliesGet(ctx context.Context, requestedUsername stri
|
|||
return nil, errWithCode
|
||||
}
|
||||
|
||||
status, err := p.db.GetStatusByID(ctx, requestedStatusID)
|
||||
status, err := p.state.DB.GetStatusByID(ctx, requestedStatusID)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorNotFound(err)
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ func (p *Processor) StatusRepliesGet(ctx context.Context, requestedUsername stri
|
|||
default:
|
||||
// scenario 3
|
||||
// get immediate children
|
||||
replies, err := p.db.GetStatusChildren(ctx, status, true, minID)
|
||||
replies, err := p.state.DB.GetStatusChildren(ctx, status, true, minID)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
// before returning a JSON serializable interface to the caller.
|
||||
func (p *Processor) UserGet(ctx context.Context, requestedUsername string, requestURL *url.URL) (interface{}, gtserror.WithCode) {
|
||||
// Get the instance-local account the request is referring to.
|
||||
requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
requestedAccount, err := p.state.DB.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ func (p *Processor) UserGet(ctx context.Context, requestedUsername string, reque
|
|||
return nil, gtserror.NewErrorUnauthorized(err)
|
||||
}
|
||||
|
||||
blocked, err := p.db.IsBlocked(ctx, requestedAccount.ID, requestingAccount.ID, true)
|
||||
blocked, err := p.state.DB.IsBlocked(ctx, requestedAccount.ID, requestingAccount.ID, true)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,12 +64,12 @@ func (p *Processor) NodeInfoRelGet(ctx context.Context) (*apimodel.WellKnownResp
|
|||
func (p *Processor) NodeInfoGet(ctx context.Context) (*apimodel.Nodeinfo, gtserror.WithCode) {
|
||||
host := config.GetHost()
|
||||
|
||||
userCount, err := p.db.CountInstanceUsers(ctx, host)
|
||||
userCount, err := p.state.DB.CountInstanceUsers(ctx, host)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
postCount, err := p.db.CountInstanceStatuses(ctx, host)
|
||||
postCount, err := p.state.DB.CountInstanceStatuses(ctx, host)
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ func (p *Processor) NodeInfoGet(ctx context.Context) (*apimodel.Nodeinfo, gtserr
|
|||
// WebfingerGet handles the GET for a webfinger resource. Most commonly, it will be used for returning account lookups.
|
||||
func (p *Processor) WebfingerGet(ctx context.Context, requestedUsername string) (*apimodel.WellKnownResponse, gtserror.WithCode) {
|
||||
// Get the local account the request is referring to.
|
||||
requestedAccount, err := p.db.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
requestedAccount, err := p.state.DB.GetAccountByUsernameDomain(ctx, requestedUsername, "")
|
||||
if err != nil {
|
||||
return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue