summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-08-15 17:01:01 +0100
committerLibravatar GitHub <noreply@github.com>2023-08-15 17:01:01 +0100
commite9c3663ccebee8f4bc7fc7132bb3c06514066a3a (patch)
treee543a9ea13f1c387f8a134a647abd6d707cc043c /internal/processing
parent[bugfix] fix inconsistent calculated cache sizes (#2115) (diff)
downloadgotosocial-e9c3663ccebee8f4bc7fc7132bb3c06514066a3a.tar.xz
[chore] ensure worker contexts have request ID (#2120)
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/workers/fromclientapi.go15
-rw-r--r--internal/processing/workers/fromfediapi.go15
2 files changed, 18 insertions, 12 deletions
diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go
index 40efc20bb..c48bb7044 100644
--- a/internal/processing/workers/fromclientapi.go
+++ b/internal/processing/workers/fromclientapi.go
@@ -25,6 +25,7 @@ import (
"codeberg.org/gruf/go-logger/v2/level"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
+ "github.com/superseriousbusiness/gotosocial/internal/gtscontext"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
@@ -46,13 +47,15 @@ type clientAPI struct {
account *account.Processor
}
-func (p *Processor) EnqueueClientAPI(ctx context.Context, msgs ...messages.FromClientAPI) {
- log.Trace(ctx, "enqueuing")
- _ = p.workers.ClientAPI.MustEnqueueCtx(ctx, func(ctx context.Context) {
+func (p *Processor) EnqueueClientAPI(cctx context.Context, msgs ...messages.FromClientAPI) {
+ _ = p.workers.ClientAPI.MustEnqueueCtx(cctx, func(wctx context.Context) {
+ // Copy caller ctx values to worker's.
+ wctx = gtscontext.WithValues(wctx, cctx)
+
+ // Process worker messages.
for _, msg := range msgs {
- log.Trace(ctx, "processing: %+v", msg)
- if err := p.ProcessFromClientAPI(ctx, msg); err != nil {
- log.Errorf(ctx, "error processing client API message: %v", err)
+ if err := p.ProcessFromClientAPI(wctx, msg); err != nil {
+ log.Errorf(wctx, "error processing client API message: %v", err)
}
}
})
diff --git a/internal/processing/workers/fromfediapi.go b/internal/processing/workers/fromfediapi.go
index 50add88a3..57e087499 100644
--- a/internal/processing/workers/fromfediapi.go
+++ b/internal/processing/workers/fromfediapi.go
@@ -24,6 +24,7 @@ import (
"codeberg.org/gruf/go-kv"
"codeberg.org/gruf/go-logger/v2/level"
"github.com/superseriousbusiness/gotosocial/internal/ap"
+ "github.com/superseriousbusiness/gotosocial/internal/gtscontext"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
@@ -44,13 +45,15 @@ type fediAPI struct {
account *account.Processor
}
-func (p *Processor) EnqueueFediAPI(ctx context.Context, msgs ...messages.FromFediAPI) {
- log.Trace(ctx, "enqueuing")
- _ = p.workers.Federator.MustEnqueueCtx(ctx, func(ctx context.Context) {
+func (p *Processor) EnqueueFediAPI(cctx context.Context, msgs ...messages.FromFediAPI) {
+ _ = p.workers.Federator.MustEnqueueCtx(cctx, func(wctx context.Context) {
+ // Copy caller ctx values to worker's.
+ wctx = gtscontext.WithValues(wctx, cctx)
+
+ // Process worker messages.
for _, msg := range msgs {
- log.Trace(ctx, "processing: %+v", msg)
- if err := p.ProcessFromFediAPI(ctx, msg); err != nil {
- log.Errorf(ctx, "error processing fedi API message: %v", err)
+ if err := p.ProcessFromFediAPI(wctx, msg); err != nil {
+ log.Errorf(wctx, "error processing fedi API message: %v", err)
}
}
})