blob: 853a067252ed7952e486aa337123f7610ab5026f [file] [log] [blame]
// Code generated by svcdec; DO NOT EDIT.
package api
import (
"context"
proto "github.com/golang/protobuf/proto"
)
type DecoratedStorage struct {
// Service is the service to decorate.
Service StorageServer
// Prelude is called for each method before forwarding the call to Service.
// If Prelude returns an error, then the call is skipped and the error is
// processed via the Postlude (if one is defined), or it is returned directly.
Prelude func(ctx context.Context, methodName string, req proto.Message) (context.Context, error)
// Postlude is called for each method after Service has processed the call, or
// after the Prelude has returned an error. This takes the the Service's
// response proto (which may be nil) and/or any error. The decorated
// service will return the response (possibly mutated) and error that Postlude
// returns.
Postlude func(ctx context.Context, methodName string, rsp proto.Message, err error) error
}
func (s *DecoratedStorage) GetObjectURL(ctx context.Context, req *GetObjectURLRequest) (rsp *ObjectURL, err error) {
if s.Prelude != nil {
var newCtx context.Context
newCtx, err = s.Prelude(ctx, "GetObjectURL", req)
if err == nil {
ctx = newCtx
}
}
if err == nil {
rsp, err = s.Service.GetObjectURL(ctx, req)
}
if s.Postlude != nil {
err = s.Postlude(ctx, "GetObjectURL", rsp, err)
}
return
}
func (s *DecoratedStorage) BeginUpload(ctx context.Context, req *BeginUploadRequest) (rsp *UploadOperation, err error) {
if s.Prelude != nil {
var newCtx context.Context
newCtx, err = s.Prelude(ctx, "BeginUpload", req)
if err == nil {
ctx = newCtx
}
}
if err == nil {
rsp, err = s.Service.BeginUpload(ctx, req)
}
if s.Postlude != nil {
err = s.Postlude(ctx, "BeginUpload", rsp, err)
}
return
}
func (s *DecoratedStorage) FinishUpload(ctx context.Context, req *FinishUploadRequest) (rsp *UploadOperation, err error) {
if s.Prelude != nil {
var newCtx context.Context
newCtx, err = s.Prelude(ctx, "FinishUpload", req)
if err == nil {
ctx = newCtx
}
}
if err == nil {
rsp, err = s.Service.FinishUpload(ctx, req)
}
if s.Postlude != nil {
err = s.Postlude(ctx, "FinishUpload", rsp, err)
}
return
}
func (s *DecoratedStorage) CancelUpload(ctx context.Context, req *CancelUploadRequest) (rsp *UploadOperation, err error) {
if s.Prelude != nil {
var newCtx context.Context
newCtx, err = s.Prelude(ctx, "CancelUpload", req)
if err == nil {
ctx = newCtx
}
}
if err == nil {
rsp, err = s.Service.CancelUpload(ctx, req)
}
if s.Postlude != nil {
err = s.Postlude(ctx, "CancelUpload", rsp, err)
}
return
}