go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/gce/api/config/v1/configurationserver_dec.go (about) 1 // Code generated by svcdec; DO NOT EDIT. 2 3 package config 4 5 import ( 6 "context" 7 8 proto "github.com/golang/protobuf/proto" 9 10 emptypb "google.golang.org/protobuf/types/known/emptypb" 11 ) 12 13 type DecoratedConfiguration struct { 14 // Service is the service to decorate. 15 Service ConfigurationServer 16 // Prelude is called for each method before forwarding the call to Service. 17 // If Prelude returns an error, then the call is skipped and the error is 18 // processed via the Postlude (if one is defined), or it is returned directly. 19 Prelude func(ctx context.Context, methodName string, req proto.Message) (context.Context, error) 20 // Postlude is called for each method after Service has processed the call, or 21 // after the Prelude has returned an error. This takes the Service's 22 // response proto (which may be nil) and/or any error. The decorated 23 // service will return the response (possibly mutated) and error that Postlude 24 // returns. 25 Postlude func(ctx context.Context, methodName string, rsp proto.Message, err error) error 26 } 27 28 func (s *DecoratedConfiguration) Delete(ctx context.Context, req *DeleteRequest) (rsp *emptypb.Empty, err error) { 29 if s.Prelude != nil { 30 var newCtx context.Context 31 newCtx, err = s.Prelude(ctx, "Delete", req) 32 if err == nil { 33 ctx = newCtx 34 } 35 } 36 if err == nil { 37 rsp, err = s.Service.Delete(ctx, req) 38 } 39 if s.Postlude != nil { 40 err = s.Postlude(ctx, "Delete", rsp, err) 41 } 42 return 43 } 44 45 func (s *DecoratedConfiguration) Ensure(ctx context.Context, req *EnsureRequest) (rsp *Config, err error) { 46 if s.Prelude != nil { 47 var newCtx context.Context 48 newCtx, err = s.Prelude(ctx, "Ensure", req) 49 if err == nil { 50 ctx = newCtx 51 } 52 } 53 if err == nil { 54 rsp, err = s.Service.Ensure(ctx, req) 55 } 56 if s.Postlude != nil { 57 err = s.Postlude(ctx, "Ensure", rsp, err) 58 } 59 return 60 } 61 62 func (s *DecoratedConfiguration) Get(ctx context.Context, req *GetRequest) (rsp *Config, err error) { 63 if s.Prelude != nil { 64 var newCtx context.Context 65 newCtx, err = s.Prelude(ctx, "Get", req) 66 if err == nil { 67 ctx = newCtx 68 } 69 } 70 if err == nil { 71 rsp, err = s.Service.Get(ctx, req) 72 } 73 if s.Postlude != nil { 74 err = s.Postlude(ctx, "Get", rsp, err) 75 } 76 return 77 } 78 79 func (s *DecoratedConfiguration) List(ctx context.Context, req *ListRequest) (rsp *ListResponse, err error) { 80 if s.Prelude != nil { 81 var newCtx context.Context 82 newCtx, err = s.Prelude(ctx, "List", req) 83 if err == nil { 84 ctx = newCtx 85 } 86 } 87 if err == nil { 88 rsp, err = s.Service.List(ctx, req) 89 } 90 if s.Postlude != nil { 91 err = s.Postlude(ctx, "List", rsp, err) 92 } 93 return 94 } 95 96 func (s *DecoratedConfiguration) Update(ctx context.Context, req *UpdateRequest) (rsp *Config, err error) { 97 if s.Prelude != nil { 98 var newCtx context.Context 99 newCtx, err = s.Prelude(ctx, "Update", req) 100 if err == nil { 101 ctx = newCtx 102 } 103 } 104 if err == nil { 105 rsp, err = s.Service.Update(ctx, req) 106 } 107 if s.Postlude != nil { 108 err = s.Postlude(ctx, "Update", rsp, err) 109 } 110 return 111 }