| // Code generated by svcdec; DO NOT EDIT. |
| |
| package config |
| |
| import ( |
| "context" |
| |
| proto "github.com/golang/protobuf/proto" |
| |
| emptypb "google.golang.org/protobuf/types/known/emptypb" |
| ) |
| |
| type DecoratedConfiguration struct { |
| // Service is the service to decorate. |
| Service ConfigurationServer |
| // 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 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 *DecoratedConfiguration) Delete(ctx context.Context, req *DeleteRequest) (rsp *emptypb.Empty, err error) { |
| if s.Prelude != nil { |
| var newCtx context.Context |
| newCtx, err = s.Prelude(ctx, "Delete", req) |
| if err == nil { |
| ctx = newCtx |
| } |
| } |
| if err == nil { |
| rsp, err = s.Service.Delete(ctx, req) |
| } |
| if s.Postlude != nil { |
| err = s.Postlude(ctx, "Delete", rsp, err) |
| } |
| return |
| } |
| |
| func (s *DecoratedConfiguration) Ensure(ctx context.Context, req *EnsureRequest) (rsp *Config, err error) { |
| if s.Prelude != nil { |
| var newCtx context.Context |
| newCtx, err = s.Prelude(ctx, "Ensure", req) |
| if err == nil { |
| ctx = newCtx |
| } |
| } |
| if err == nil { |
| rsp, err = s.Service.Ensure(ctx, req) |
| } |
| if s.Postlude != nil { |
| err = s.Postlude(ctx, "Ensure", rsp, err) |
| } |
| return |
| } |
| |
| func (s *DecoratedConfiguration) Get(ctx context.Context, req *GetRequest) (rsp *Config, err error) { |
| if s.Prelude != nil { |
| var newCtx context.Context |
| newCtx, err = s.Prelude(ctx, "Get", req) |
| if err == nil { |
| ctx = newCtx |
| } |
| } |
| if err == nil { |
| rsp, err = s.Service.Get(ctx, req) |
| } |
| if s.Postlude != nil { |
| err = s.Postlude(ctx, "Get", rsp, err) |
| } |
| return |
| } |
| |
| func (s *DecoratedConfiguration) List(ctx context.Context, req *ListRequest) (rsp *ListResponse, err error) { |
| if s.Prelude != nil { |
| var newCtx context.Context |
| newCtx, err = s.Prelude(ctx, "List", req) |
| if err == nil { |
| ctx = newCtx |
| } |
| } |
| if err == nil { |
| rsp, err = s.Service.List(ctx, req) |
| } |
| if s.Postlude != nil { |
| err = s.Postlude(ctx, "List", rsp, err) |
| } |
| return |
| } |
| |
| func (s *DecoratedConfiguration) Update(ctx context.Context, req *UpdateRequest) (rsp *Config, err error) { |
| if s.Prelude != nil { |
| var newCtx context.Context |
| newCtx, err = s.Prelude(ctx, "Update", req) |
| if err == nil { |
| ctx = newCtx |
| } |
| } |
| if err == nil { |
| rsp, err = s.Service.Update(ctx, req) |
| } |
| if s.Postlude != nil { |
| err = s.Postlude(ctx, "Update", rsp, err) |
| } |
| return |
| } |