Retain execution controls in prepared handles
This commit is contained in:
@@ -29,6 +29,8 @@ type PreparedExecution struct {
|
||||
}
|
||||
|
||||
type preparedExecutionPayload struct {
|
||||
operationTimeout time.Duration
|
||||
onPrepared func(context.Context, *domain.PreparedRun)
|
||||
prepared *domain.PreparedRun
|
||||
capture bool
|
||||
parent *domain.Exchange
|
||||
@@ -56,6 +58,8 @@ func (r *Runner) PrepareExecution(ctx context.Context, req domain.RunRequest) (*
|
||||
state: preparedExecutionReady,
|
||||
details: operation.run,
|
||||
payload: &preparedExecutionPayload{
|
||||
operationTimeout: req.OperationTimeout,
|
||||
onPrepared: req.OnPrepared,
|
||||
prepared: operation.run,
|
||||
capture: operation.capture,
|
||||
parent: operation.parent,
|
||||
@@ -100,12 +104,16 @@ func (p *PreparedExecution) Discard() {
|
||||
}
|
||||
|
||||
// RunPrepared claims and executes one prepared execution owned by this runner.
|
||||
func (r *Runner) RunPrepared(ctx context.Context, prepared *PreparedExecution) (*domain.RunResult, error) {
|
||||
func (r *Runner) RunPrepared(ctx context.Context, prepared *PreparedExecution) (result *domain.RunResult, err error) {
|
||||
payload, err := prepared.claim(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer payload.clear()
|
||||
scope := NewOperationScope(ctx, payload.operationTimeout)
|
||||
defer scope.Close()
|
||||
defer func() { err = scope.Finalize(err) }()
|
||||
ctx = scope.Context
|
||||
|
||||
var recorder *observation.Recorder
|
||||
var runID string
|
||||
@@ -185,6 +193,8 @@ func (p *preparedExecutionPayload) clear() {
|
||||
p.directKey = ""
|
||||
p.transientRetries = 0
|
||||
p.observer = nil
|
||||
p.operationTimeout = 0
|
||||
p.onPrepared = nil
|
||||
}
|
||||
|
||||
type noOpPreparedValidation struct {
|
||||
|
||||
Reference in New Issue
Block a user