aclsvc/v2: Allocate RequestContext once
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
2d3bed89d2
commit
d9ab944c22
1 changed files with 21 additions and 21 deletions
|
@ -108,21 +108,21 @@ func New(next object.ServiceServer,
|
|||
type wrappedGetObjectStream struct {
|
||||
object.GetObjectStream
|
||||
|
||||
requestInfo RequestInfo
|
||||
requestContext *object.RequestContext
|
||||
}
|
||||
|
||||
func (w *wrappedGetObjectStream) Context() context.Context {
|
||||
return object.NewRequestContext(w.GetObjectStream.Context(), &object.RequestContext{
|
||||
Namespace: w.requestInfo.ContainerNamespace(),
|
||||
SenderKey: w.requestInfo.SenderKey(),
|
||||
Role: w.requestInfo.RequestRole(),
|
||||
})
|
||||
return object.NewRequestContext(w.GetObjectStream.Context(), w.requestContext)
|
||||
}
|
||||
|
||||
func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream {
|
||||
return &wrappedGetObjectStream{
|
||||
GetObjectStream: getObjectStream,
|
||||
requestInfo: reqInfo,
|
||||
requestContext: &object.RequestContext{
|
||||
Namespace: reqInfo.ContainerNamespace(),
|
||||
SenderKey: reqInfo.SenderKey(),
|
||||
Role: reqInfo.RequestRole(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,21 +131,21 @@ func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, req
|
|||
type wrappedRangeStream struct {
|
||||
object.GetObjectRangeStream
|
||||
|
||||
requestInfo RequestInfo
|
||||
requestContext *object.RequestContext
|
||||
}
|
||||
|
||||
func (w *wrappedRangeStream) Context() context.Context {
|
||||
return object.NewRequestContext(w.GetObjectRangeStream.Context(), &object.RequestContext{
|
||||
Namespace: w.requestInfo.ContainerNamespace(),
|
||||
SenderKey: w.requestInfo.SenderKey(),
|
||||
Role: w.requestInfo.RequestRole(),
|
||||
})
|
||||
return object.NewRequestContext(w.GetObjectRangeStream.Context(), w.requestContext)
|
||||
}
|
||||
|
||||
func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream {
|
||||
return &wrappedRangeStream{
|
||||
GetObjectRangeStream: rangeStream,
|
||||
requestInfo: reqInfo,
|
||||
requestContext: &object.RequestContext{
|
||||
Namespace: reqInfo.ContainerNamespace(),
|
||||
SenderKey: reqInfo.SenderKey(),
|
||||
Role: reqInfo.RequestRole(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,21 +154,21 @@ func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo Requ
|
|||
type wrappedSearchStream struct {
|
||||
object.SearchStream
|
||||
|
||||
requestInfo RequestInfo
|
||||
requestContext *object.RequestContext
|
||||
}
|
||||
|
||||
func (w *wrappedSearchStream) Context() context.Context {
|
||||
return object.NewRequestContext(w.SearchStream.Context(), &object.RequestContext{
|
||||
Namespace: w.requestInfo.ContainerNamespace(),
|
||||
SenderKey: w.requestInfo.SenderKey(),
|
||||
Role: w.requestInfo.RequestRole(),
|
||||
})
|
||||
return object.NewRequestContext(w.SearchStream.Context(), w.requestContext)
|
||||
}
|
||||
|
||||
func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream {
|
||||
return &wrappedSearchStream{
|
||||
SearchStream: searchStream,
|
||||
requestInfo: reqInfo,
|
||||
requestContext: &object.RequestContext{
|
||||
Namespace: reqInfo.ContainerNamespace(),
|
||||
SenderKey: reqInfo.SenderKey(),
|
||||
Role: reqInfo.RequestRole(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue