go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/swarming/proto/api/externalschedulerserver_dec.go (about)

     1  // Code generated by svcdec; DO NOT EDIT.
     2  
     3  package apipb
     4  
     5  import (
     6  	"context"
     7  
     8  	proto "github.com/golang/protobuf/proto"
     9  )
    10  
    11  type DecoratedExternalScheduler struct {
    12  	// Service is the service to decorate.
    13  	Service ExternalSchedulerServer
    14  	// Prelude is called for each method before forwarding the call to Service.
    15  	// If Prelude returns an error, then the call is skipped and the error is
    16  	// processed via the Postlude (if one is defined), or it is returned directly.
    17  	Prelude func(ctx context.Context, methodName string, req proto.Message) (context.Context, error)
    18  	// Postlude is called for each method after Service has processed the call, or
    19  	// after the Prelude has returned an error. This takes the Service's
    20  	// response proto (which may be nil) and/or any error. The decorated
    21  	// service will return the response (possibly mutated) and error that Postlude
    22  	// returns.
    23  	Postlude func(ctx context.Context, methodName string, rsp proto.Message, err error) error
    24  }
    25  
    26  func (s *DecoratedExternalScheduler) AssignTasks(ctx context.Context, req *AssignTasksRequest) (rsp *AssignTasksResponse, err error) {
    27  	if s.Prelude != nil {
    28  		var newCtx context.Context
    29  		newCtx, err = s.Prelude(ctx, "AssignTasks", req)
    30  		if err == nil {
    31  			ctx = newCtx
    32  		}
    33  	}
    34  	if err == nil {
    35  		rsp, err = s.Service.AssignTasks(ctx, req)
    36  	}
    37  	if s.Postlude != nil {
    38  		err = s.Postlude(ctx, "AssignTasks", rsp, err)
    39  	}
    40  	return
    41  }
    42  
    43  func (s *DecoratedExternalScheduler) GetCancellations(ctx context.Context, req *GetCancellationsRequest) (rsp *GetCancellationsResponse, err error) {
    44  	if s.Prelude != nil {
    45  		var newCtx context.Context
    46  		newCtx, err = s.Prelude(ctx, "GetCancellations", req)
    47  		if err == nil {
    48  			ctx = newCtx
    49  		}
    50  	}
    51  	if err == nil {
    52  		rsp, err = s.Service.GetCancellations(ctx, req)
    53  	}
    54  	if s.Postlude != nil {
    55  		err = s.Postlude(ctx, "GetCancellations", rsp, err)
    56  	}
    57  	return
    58  }
    59  
    60  func (s *DecoratedExternalScheduler) NotifyTasks(ctx context.Context, req *NotifyTasksRequest) (rsp *NotifyTasksResponse, err error) {
    61  	if s.Prelude != nil {
    62  		var newCtx context.Context
    63  		newCtx, err = s.Prelude(ctx, "NotifyTasks", req)
    64  		if err == nil {
    65  			ctx = newCtx
    66  		}
    67  	}
    68  	if err == nil {
    69  		rsp, err = s.Service.NotifyTasks(ctx, req)
    70  	}
    71  	if s.Postlude != nil {
    72  		err = s.Postlude(ctx, "NotifyTasks", rsp, err)
    73  	}
    74  	return
    75  }
    76  
    77  func (s *DecoratedExternalScheduler) GetCallbacks(ctx context.Context, req *GetCallbacksRequest) (rsp *GetCallbacksResponse, err error) {
    78  	if s.Prelude != nil {
    79  		var newCtx context.Context
    80  		newCtx, err = s.Prelude(ctx, "GetCallbacks", req)
    81  		if err == nil {
    82  			ctx = newCtx
    83  		}
    84  	}
    85  	if err == nil {
    86  		rsp, err = s.Service.GetCallbacks(ctx, req)
    87  	}
    88  	if s.Postlude != nil {
    89  		err = s.Postlude(ctx, "GetCallbacks", rsp, err)
    90  	}
    91  	return
    92  }