mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-23 13:30:23 +00:00
fb7dc13dfe
updated few packages in go.mod to latest available release. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
31 lines
929 B
Go
31 lines
929 B
Go
// Copyright 2016 Michal Witkowski. All Rights Reserved.
|
|
// See LICENSE for licensing terms.
|
|
|
|
package grpc_middleware
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.
|
|
type WrappedServerStream struct {
|
|
grpc.ServerStream
|
|
// WrappedContext is the wrapper's own Context. You can assign it.
|
|
WrappedContext context.Context
|
|
}
|
|
|
|
// Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()
|
|
func (w *WrappedServerStream) Context() context.Context {
|
|
return w.WrappedContext
|
|
}
|
|
|
|
// WrapServerStream returns a ServerStream that has the ability to overwrite context.
|
|
func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream {
|
|
if existing, ok := stream.(*WrappedServerStream); ok {
|
|
return existing
|
|
}
|
|
return &WrappedServerStream{ServerStream: stream, WrappedContext: stream.Context()}
|
|
}
|