@@ -49,15 +49,16 @@ type Executor interface {
49
49
type grpcExecutor struct {
50
50
protos.UnimplementedTaskHubSidecarServiceServer
51
51
52
- workItemQueue chan * protos.WorkItem
53
- pendingOrchestrators * sync.Map // map[api.InstanceID]*ExecutionResults
54
- pendingActivities * sync.Map // map[string]*activityExecutionResult
55
- backend Backend
56
- logger Logger
57
- onWorkItemConnection func (context.Context ) error
58
- onWorkItemDisconnect func (context.Context ) error
59
- streamShutdownChan <- chan any
60
- streamSendTimeout * time.Duration
52
+ workItemQueue chan * protos.WorkItem
53
+ pendingOrchestrators * sync.Map // map[api.InstanceID]*ExecutionResults
54
+ pendingActivities * sync.Map // map[string]*activityExecutionResult
55
+ backend Backend
56
+ logger Logger
57
+ onWorkItemConnection func (context.Context ) error
58
+ onWorkItemDisconnect func (context.Context ) error
59
+ streamShutdownChan <- chan any
60
+ streamSendTimeout * time.Duration
61
+ skipWaitForInstanceStart bool
61
62
}
62
63
63
64
type grpcExecutorOptions func (g * grpcExecutor )
@@ -98,6 +99,12 @@ func WithStreamSendTimeout(d time.Duration) grpcExecutorOptions {
98
99
}
99
100
}
100
101
102
+ func WithSkipWaitForInstanceStart () grpcExecutorOptions {
103
+ return func (g * grpcExecutor ) {
104
+ g .skipWaitForInstanceStart = true
105
+ }
106
+ }
107
+
101
108
// NewGrpcExecutor returns the Executor object and a method to invoke to register the gRPC server in the executor.
102
109
func NewGrpcExecutor (be Backend , logger Logger , opts ... grpcExecutorOptions ) (executor Executor , registerServerFn func (grpcServer grpc.ServiceRegistrar )) {
103
110
grpcExecutor := & grpcExecutor {
@@ -506,12 +513,14 @@ func (g *grpcExecutor) StartInstance(ctx context.Context, req *protos.CreateInst
506
513
},
507
514
}
508
515
if err := g .backend .CreateOrchestrationInstance (ctx , e , WithOrchestrationIdReusePolicy (req .OrchestrationIdReusePolicy )); err != nil {
509
- return nil , err
516
+ return nil , fmt . Errorf ( "failed to create orchestration instance: %w" , err )
510
517
}
511
518
512
- _ , err := g .WaitForInstanceStart (ctx , & protos.GetInstanceRequest {InstanceId : instanceID })
513
- if err != nil {
514
- return nil , err
519
+ if ! g .skipWaitForInstanceStart {
520
+ _ , err := g .WaitForInstanceStart (ctx , & protos.GetInstanceRequest {InstanceId : instanceID })
521
+ if err != nil {
522
+ return nil , err
523
+ }
515
524
}
516
525
517
526
return & protos.CreateInstanceResponse {InstanceId : instanceID }, nil
0 commit comments