mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-07 04:40:05 -06:00
Pass context to event publishing.
To allow tracing propagation via events, we need to pass the context to the `Publish` function of reva events. This adds the context everywhere where events are published. If there was no context to pass, we started a new one with `context.Background()`.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
@@ -38,7 +39,7 @@ func RestartPostprocessing(cfg *config.Config) *cli.Command {
|
||||
Timestamp: utils.TSNow(),
|
||||
}
|
||||
|
||||
if err := events.Publish(stream, ev); err != nil {
|
||||
if err := events.Publish(context.Background(), stream, ev); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
@@ -88,7 +89,7 @@ func (pps *PostprocessingService) Run() error {
|
||||
pp, err = getPP(pps.store, ev.UploadID)
|
||||
if err != nil {
|
||||
if err == store.ErrNotFound {
|
||||
if err := events.Publish(pps.pub, events.RestartPostprocessing{
|
||||
if err := events.Publish(context.Background(), pps.pub, events.RestartPostprocessing{
|
||||
UploadID: ev.UploadID,
|
||||
Timestamp: ev.Timestamp,
|
||||
}); err != nil {
|
||||
@@ -109,7 +110,7 @@ func (pps *PostprocessingService) Run() error {
|
||||
}
|
||||
}
|
||||
if next != nil {
|
||||
if err := events.Publish(pps.pub, next); err != nil {
|
||||
if err := events.Publish(context.Background(), pps.pub, next); err != nil {
|
||||
pps.log.Error().Err(err).Msg("unable to publish event")
|
||||
return err // we can't publish -> we are screwed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user