WIP: Cache head results in the request context #974

Closed
fyrchik wants to merge 6 commits from fyrchik/frostfs-node:head-cache into master
Showing only changes of commit 81880f92fb - Show all commits

View file

@ -108,23 +108,23 @@ func New(next object.ServiceServer,
type wrappedGetObjectStream struct { type wrappedGetObjectStream struct {
object.GetObjectStream object.GetObjectStream
requestInfo RequestInfo requestContext *object.RequestContext
} }
func (w *wrappedGetObjectStream) Context() context.Context { func (w *wrappedGetObjectStream) Context() context.Context {
return object.NewRequestContext(w.GetObjectStream.Context(), &object.RequestContext{ return object.NewRequestContext(w.GetObjectStream.Context(), w.requestContext)
Namespace: w.requestInfo.ContainerNamespace(),
ContainerOwner: w.requestInfo.ContainerOwner(),
SenderKey: w.requestInfo.SenderKey(),
Role: w.requestInfo.RequestRole(),
SoftAPECheck: w.requestInfo.IsSoftAPECheck(),
})
} }
func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream { func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, reqInfo RequestInfo) object.GetObjectStream {
return &wrappedGetObjectStream{ return &wrappedGetObjectStream{
GetObjectStream: getObjectStream, GetObjectStream: getObjectStream,
requestInfo: reqInfo, requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
} }
} }
@ -133,23 +133,23 @@ func newWrappedGetObjectStreamStream(getObjectStream object.GetObjectStream, req
type wrappedRangeStream struct { type wrappedRangeStream struct {
object.GetObjectRangeStream object.GetObjectRangeStream
requestInfo RequestInfo requestContext *object.RequestContext
} }
func (w *wrappedRangeStream) Context() context.Context { func (w *wrappedRangeStream) Context() context.Context {
return object.NewRequestContext(w.GetObjectRangeStream.Context(), &object.RequestContext{ return object.NewRequestContext(w.GetObjectRangeStream.Context(), w.requestContext)
Namespace: w.requestInfo.ContainerNamespace(),
ContainerOwner: w.requestInfo.ContainerOwner(),
SenderKey: w.requestInfo.SenderKey(),
Role: w.requestInfo.RequestRole(),
SoftAPECheck: w.requestInfo.IsSoftAPECheck(),
})
} }
func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream { func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo RequestInfo) object.GetObjectRangeStream {
return &wrappedRangeStream{ return &wrappedRangeStream{
GetObjectRangeStream: rangeStream, GetObjectRangeStream: rangeStream,
requestInfo: reqInfo, requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
} }
} }
@ -158,23 +158,23 @@ func newWrappedRangeStream(rangeStream object.GetObjectRangeStream, reqInfo Requ
type wrappedSearchStream struct { type wrappedSearchStream struct {
object.SearchStream object.SearchStream
requestInfo RequestInfo requestContext *object.RequestContext
} }
func (w *wrappedSearchStream) Context() context.Context { func (w *wrappedSearchStream) Context() context.Context {
return object.NewRequestContext(w.SearchStream.Context(), &object.RequestContext{ return object.NewRequestContext(w.SearchStream.Context(), w.requestContext)
Namespace: w.requestInfo.ContainerNamespace(),
ContainerOwner: w.requestInfo.ContainerOwner(),
SenderKey: w.requestInfo.SenderKey(),
Role: w.requestInfo.RequestRole(),
SoftAPECheck: w.requestInfo.IsSoftAPECheck(),
})
} }
func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream { func newWrappedSearchStream(searchStream object.SearchStream, reqInfo RequestInfo) object.SearchStream {
return &wrappedSearchStream{ return &wrappedSearchStream{
SearchStream: searchStream, SearchStream: searchStream,
requestInfo: reqInfo, requestContext: &object.RequestContext{
Namespace: reqInfo.ContainerNamespace(),
ContainerOwner: reqInfo.ContainerOwner(),
SenderKey: reqInfo.SenderKey(),
Role: reqInfo.RequestRole(),
SoftAPECheck: reqInfo.IsSoftAPECheck(),
},
} }
} }