go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/examples/appengine/quotabeta/proto/demoserver_dec.go (about)

     1  // Code generated by svcdec; DO NOT EDIT.
     2  
     3  package proto
     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 DecoratedDemo struct {
    14  	// Service is the service to decorate.
    15  	Service DemoServer
    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 *DecoratedDemo) GlobalRateLimit(ctx context.Context, req *emptypb.Empty) (rsp *emptypb.Empty, err error) {
    29  	if s.Prelude != nil {
    30  		var newCtx context.Context
    31  		newCtx, err = s.Prelude(ctx, "GlobalRateLimit", req)
    32  		if err == nil {
    33  			ctx = newCtx
    34  		}
    35  	}
    36  	if err == nil {
    37  		rsp, err = s.Service.GlobalRateLimit(ctx, req)
    38  	}
    39  	if s.Postlude != nil {
    40  		err = s.Postlude(ctx, "GlobalRateLimit", rsp, err)
    41  	}
    42  	return
    43  }
    44  
    45  func (s *DecoratedDemo) GlobalQuotaReset(ctx context.Context, req *emptypb.Empty) (rsp *emptypb.Empty, err error) {
    46  	if s.Prelude != nil {
    47  		var newCtx context.Context
    48  		newCtx, err = s.Prelude(ctx, "GlobalQuotaReset", req)
    49  		if err == nil {
    50  			ctx = newCtx
    51  		}
    52  	}
    53  	if err == nil {
    54  		rsp, err = s.Service.GlobalQuotaReset(ctx, req)
    55  	}
    56  	if s.Postlude != nil {
    57  		err = s.Postlude(ctx, "GlobalQuotaReset", rsp, err)
    58  	}
    59  	return
    60  }
    61  
    62  func (s *DecoratedDemo) PerUserRateLimit(ctx context.Context, req *emptypb.Empty) (rsp *emptypb.Empty, err error) {
    63  	if s.Prelude != nil {
    64  		var newCtx context.Context
    65  		newCtx, err = s.Prelude(ctx, "PerUserRateLimit", req)
    66  		if err == nil {
    67  			ctx = newCtx
    68  		}
    69  	}
    70  	if err == nil {
    71  		rsp, err = s.Service.PerUserRateLimit(ctx, req)
    72  	}
    73  	if s.Postlude != nil {
    74  		err = s.Postlude(ctx, "PerUserRateLimit", rsp, err)
    75  	}
    76  	return
    77  }
    78  
    79  func (s *DecoratedDemo) PerUserQuotaReset(ctx context.Context, req *emptypb.Empty) (rsp *emptypb.Empty, err error) {
    80  	if s.Prelude != nil {
    81  		var newCtx context.Context
    82  		newCtx, err = s.Prelude(ctx, "PerUserQuotaReset", req)
    83  		if err == nil {
    84  			ctx = newCtx
    85  		}
    86  	}
    87  	if err == nil {
    88  		rsp, err = s.Service.PerUserQuotaReset(ctx, req)
    89  	}
    90  	if s.Postlude != nil {
    91  		err = s.Postlude(ctx, "PerUserQuotaReset", rsp, err)
    92  	}
    93  	return
    94  }