Pass context from gRPC streams to background tasks
This commit is contained in:
parent
6dde29cdcf
commit
54e9bc0d2c
|
@ -53,7 +53,7 @@ func (c *mediaSetServiceController) Get(ctx context.Context, request *pbmediaset
|
||||||
// part of the MediaSet.
|
// part of the MediaSet.
|
||||||
func (c *mediaSetServiceController) GetPeaks(request *pbmediaset.GetPeaksRequest, stream pbmediaset.MediaSetService_GetPeaksServer) error {
|
func (c *mediaSetServiceController) GetPeaks(request *pbmediaset.GetPeaksRequest, stream pbmediaset.MediaSetService_GetPeaksServer) error {
|
||||||
// TODO: reduce timeout when fetching from S3
|
// TODO: reduce timeout when fetching from S3
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), getPeaksTimeout)
|
ctx, cancel := context.WithTimeout(stream.Context(), getPeaksTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
id, err := uuid.Parse(request.GetId())
|
id, err := uuid.Parse(request.GetId())
|
||||||
|
@ -118,7 +118,7 @@ func (c *mediaSetServiceController) GetPeaksForSegment(ctx context.Context, requ
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *mediaSetServiceController) GetAudioSegment(request *pbmediaset.GetAudioSegmentRequest, outStream pbmediaset.MediaSetService_GetAudioSegmentServer) error {
|
func (c *mediaSetServiceController) GetAudioSegment(request *pbmediaset.GetAudioSegmentRequest, outStream pbmediaset.MediaSetService_GetAudioSegmentServer) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), getPeaksForSegmentTimeout)
|
ctx, cancel := context.WithTimeout(outStream.Context(), getPeaksForSegmentTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
id, err := uuid.Parse(request.GetId())
|
id, err := uuid.Parse(request.GetId())
|
||||||
|
@ -164,7 +164,7 @@ func (c *mediaSetServiceController) GetAudioSegment(request *pbmediaset.GetAudio
|
||||||
|
|
||||||
func (c *mediaSetServiceController) GetVideo(request *pbmediaset.GetVideoRequest, stream pbmediaset.MediaSetService_GetVideoServer) error {
|
func (c *mediaSetServiceController) GetVideo(request *pbmediaset.GetVideoRequest, stream pbmediaset.MediaSetService_GetVideoServer) error {
|
||||||
// TODO: reduce timeout when already fetched from Youtube
|
// TODO: reduce timeout when already fetched from Youtube
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), getVideoTimeout)
|
ctx, cancel := context.WithTimeout(stream.Context(), getVideoTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
id, err := uuid.Parse(request.GetId())
|
id, err := uuid.Parse(request.GetId())
|
||||||
|
|
Loading…
Reference in New Issue