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
|
@ -170,3 +170,59 @@ func (a *auditPutStream) Send(ctx context.Context, req *object.PutRequest) error
|
|||
}
|
||||
return err
|
||||
}
|
||||
|
||||
type auditPatchStream struct {
|
||||
stream PatchObjectstream
|
||||
log *logger.Logger
|
||||
|
||||
failed bool
|
||||
key []byte
|
||||
containerID *refs.ContainerID
|
||||
objectID *refs.ObjectID
|
||||
}
|
||||
|
||||
func (a *auditService) Patch() (PatchObjectstream, error) {
|
||||
res, err := a.next.Patch()
|
||||
if !a.enabled.Load() {
|
||||
return res, err
|
||||
}
|
||||
if err != nil {
|
||||
audit.LogRequest(a.log, objectGRPC.ObjectService_Patch_FullMethodName, nil, nil, false)
|
||||
return res, err
|
||||
}
|
||||
return &auditPatchStream{
|
||||
stream: res,
|
||||
log: a.log,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CloseAndRecv implements PutObjectStream.
|
||||
func (a *auditPatchStream) CloseAndRecv(ctx context.Context) (*object.PatchResponse, error) {
|
||||
resp, err := a.stream.CloseAndRecv(ctx)
|
||||
if err != nil {
|
||||
a.failed = true
|
||||
}
|
||||
a.objectID = resp.GetBody().ObjectID
|
||||
audit.LogRequestWithKey(a.log, objectGRPC.ObjectService_Patch_FullMethodName, a.key,
|
||||
audit.TargetFromContainerIDObjectID(a.containerID, a.objectID),
|
||||
!a.failed)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// Send implements PutObjectStream.
|
||||
func (a *auditPatchStream) Send(ctx context.Context, req *object.PatchRequest) error {
|
||||
a.containerID = req.GetBody().GetAddress().GetContainerID()
|
||||
a.objectID = req.GetBody().GetAddress().GetObjectID()
|
||||
a.key = req.GetVerificationHeader().GetBodySignature().GetKey()
|
||||
|
||||
err := a.stream.Send(ctx, req)
|
||||
if err != nil {
|
||||
a.failed = true
|
||||
}
|
||||
if !errors.Is(err, util.ErrAbortStream) { // CloseAndRecv will not be called, so log here
|
||||
audit.LogRequestWithKey(a.log, objectGRPC.ObjectService_Patch_FullMethodName, a.key,
|
||||
audit.TargetFromContainerIDObjectID(a.containerID, a.objectID),
|
||||
!a.failed)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue