forked from TrueCloudLab/frostfs-node
[#1307] go.mod: Bump frostfs-sdk-go/frostfs-api-go/v2 versions
* Also, resolve dependencies and conflicts for object service by creating stub for `Patch` method. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
ec1509de4e
commit
a4a1c3f18b
15 changed files with 345 additions and 11 deletions
|
@ -27,6 +27,12 @@ type (
|
|||
start time.Time
|
||||
}
|
||||
|
||||
patchStreamMetric struct {
|
||||
stream PatchObjectstream
|
||||
metrics MetricRegister
|
||||
start time.Time
|
||||
}
|
||||
|
||||
MetricRegister interface {
|
||||
AddRequestDuration(string, time.Duration, bool)
|
||||
AddPayloadSize(string, int)
|
||||
|
@ -76,6 +82,24 @@ func (m MetricCollector) Put() (PutObjectStream, error) {
|
|||
return m.next.Put()
|
||||
}
|
||||
|
||||
func (m MetricCollector) Patch() (PatchObjectstream, error) {
|
||||
if m.enabled {
|
||||
t := time.Now()
|
||||
|
||||
stream, err := m.next.Patch()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &patchStreamMetric{
|
||||
stream: stream,
|
||||
metrics: m.metrics,
|
||||
start: t,
|
||||
}, nil
|
||||
}
|
||||
return m.next.Patch()
|
||||
}
|
||||
|
||||
func (m MetricCollector) PutSingle(ctx context.Context, request *object.PutSingleRequest) (*object.PutSingleResponse, error) {
|
||||
if m.enabled {
|
||||
t := time.Now()
|
||||
|
@ -189,3 +213,16 @@ func (s putStreamMetric) CloseAndRecv(ctx context.Context) (*object.PutResponse,
|
|||
|
||||
return res, err
|
||||
}
|
||||
func (s patchStreamMetric) Send(ctx context.Context, req *object.PatchRequest) error {
|
||||
s.metrics.AddPayloadSize("Patch", len(req.GetBody().GetPatch().Chunk))
|
||||
|
||||
return s.stream.Send(ctx, req)
|
||||
}
|
||||
|
||||
func (s patchStreamMetric) CloseAndRecv(ctx context.Context) (*object.PatchResponse, error) {
|
||||
res, err := s.stream.CloseAndRecv(ctx)
|
||||
|
||||
s.metrics.AddRequestDuration("Patch", time.Since(s.start), err == nil)
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue