@@ -77,22 +77,22 @@ type RunDetails struct {
7777type AdminClient interface {
7878 // Deprecated: PutWorkflow is part of the legacy v0 workflow definition system.
7979 // Use the new Go SDK at github.com/hatchet-dev/hatchet/sdks/go instead. Migration guide: https://docs.hatchet.run/home/migration-guide-go
80- PutWorkflow (workflow * types.Workflow , opts ... PutOptFunc ) error
80+ PutWorkflow (ctx context. Context , workflow * types.Workflow , opts ... PutOptFunc ) error //nolint:staticcheck // SA1019: Retained for backwards compatability
8181 // Deprecated: PutWorkflowV1 is an internal method used by the new Go SDK.
8282 // Use the new Go SDK at github.com/hatchet-dev/hatchet/sdks/go instead of calling this directly. Migration guide: https://docs.hatchet.run/home/migration-guide-go
83- PutWorkflowV1 (workflow * v1contracts.CreateWorkflowVersionRequest , opts ... PutOptFunc ) error
83+ PutWorkflowV1 (ctx context. Context , workflow * v1contracts.CreateWorkflowVersionRequest , opts ... PutOptFunc ) error
8484
85- ScheduleWorkflow (workflowName string , opts ... ScheduleOptFunc ) error
85+ ScheduleWorkflow (ctx context. Context , workflowName string , opts ... ScheduleOptFunc ) error
8686
8787 // RunWorkflow triggers a workflow run and returns the run id
88- RunWorkflow (workflowName string , input interface {}, opts ... RunOptFunc ) (* Workflow , error )
88+ RunWorkflow (ctx context. Context , workflowName string , input interface {}, opts ... RunOptFunc ) (* Workflow , error )
8989
90- BulkRunWorkflow (workflows []* WorkflowRun ) ([]string , error )
90+ BulkRunWorkflow (ctx context. Context , workflows []* WorkflowRun ) ([]string , error )
9191
92- RunChildWorkflow (workflowName string , input interface {}, opts * ChildWorkflowOpts ) (string , error )
93- RunChildWorkflows (workflows []* RunChildWorkflowsOpts ) ([]string , error )
92+ RunChildWorkflow (ctx context. Context , workflowName string , input interface {}, opts * ChildWorkflowOpts ) (string , error )
93+ RunChildWorkflows (ctx context. Context , workflows []* RunChildWorkflowsOpts ) ([]string , error )
9494
95- PutRateLimit (key string , opts * types.RateLimitOpts ) error
95+ PutRateLimit (ctx context. Context , key string , opts * types.RateLimitOpts ) error
9696
9797 GetRunDetails (ctx context.Context , externalId uuid.UUID ) (* RunDetails , error )
9898}
@@ -149,7 +149,7 @@ func defaultPutOpts() *putOpts {
149149
150150// Deprecated: PutWorkflow is part of the legacy v0 workflow definition system.
151151// Use the new Go SDK at github.com/hatchet-dev/hatchet/sdks/go instead. Migration guide: https://docs.hatchet.run/home/migration-guide-go
152- func (a * adminClientImpl ) PutWorkflow (workflow * types.Workflow , fs ... PutOptFunc ) error {
152+ func (a * adminClientImpl ) PutWorkflow (ctx context. Context , workflow * types.Workflow , fs ... PutOptFunc ) error {
153153 opts := defaultPutOpts ()
154154
155155 for _ , f := range fs {
@@ -162,7 +162,7 @@ func (a *adminClientImpl) PutWorkflow(workflow *types.Workflow, fs ...PutOptFunc
162162 return fmt .Errorf ("could not get put opts: %w" , err )
163163 }
164164
165- _ , err = a .client .PutWorkflow (a .ctx .newContext (context . Background () ), req )
165+ _ , err = a .client .PutWorkflow (a .ctx .newContext (ctx ), req )
166166
167167 if err != nil {
168168 return fmt .Errorf ("could not create workflow %s: %w" , workflow .Name , err )
@@ -173,14 +173,14 @@ func (a *adminClientImpl) PutWorkflow(workflow *types.Workflow, fs ...PutOptFunc
173173
174174// Deprecated: PutWorkflowV1 is an internal method used by the new Go SDK.
175175// Use the new Go SDK at github.com/hatchet-dev/hatchet/sdks/go instead of calling this directly. Migration guide: https://docs.hatchet.run/home/migration-guide-go
176- func (a * adminClientImpl ) PutWorkflowV1 (workflow * v1contracts.CreateWorkflowVersionRequest , fs ... PutOptFunc ) error {
176+ func (a * adminClientImpl ) PutWorkflowV1 (ctx context. Context , workflow * v1contracts.CreateWorkflowVersionRequest , fs ... PutOptFunc ) error {
177177 opts := defaultPutOpts ()
178178
179179 for _ , f := range fs {
180180 f (opts )
181181 }
182182
183- _ , err := a .v1Client .PutWorkflow (a .ctx .newContext (context . Background () ), workflow )
183+ _ , err := a .v1Client .PutWorkflow (a .ctx .newContext (ctx ), workflow )
184184
185185 if err != nil {
186186 return fmt .Errorf ("could not create workflow %s: %w" , workflow .Name , err )
@@ -213,7 +213,7 @@ func defaultScheduleOpts() *scheduleOpts {
213213 return & scheduleOpts {}
214214}
215215
216- func (a * adminClientImpl ) ScheduleWorkflow (workflowName string , fs ... ScheduleOptFunc ) error {
216+ func (a * adminClientImpl ) ScheduleWorkflow (ctx context. Context , workflowName string , fs ... ScheduleOptFunc ) error {
217217 opts := defaultScheduleOpts ()
218218
219219 for _ , f := range fs {
@@ -238,7 +238,7 @@ func (a *adminClientImpl) ScheduleWorkflow(workflowName string, fs ...ScheduleOp
238238
239239 workflowName = client .ApplyNamespace (workflowName , & a .namespace )
240240
241- _ , err = a .client .ScheduleWorkflow (a .ctx .newContext (context . Background () ), & admincontracts.ScheduleWorkflowRequest {
241+ _ , err = a .client .ScheduleWorkflow (a .ctx .newContext (ctx ), & admincontracts.ScheduleWorkflowRequest {
242242 Name : workflowName ,
243243 Schedules : pbSchedules ,
244244 Input : string (inputBytes ),
@@ -285,7 +285,7 @@ func WithPriority(priority int32) RunOptFunc {
285285// }
286286// }
287287
288- func (a * adminClientImpl ) RunWorkflow (workflowName string , input interface {}, options ... RunOptFunc ) (* Workflow , error ) {
288+ func (a * adminClientImpl ) RunWorkflow (ctx context. Context , workflowName string , input interface {}, options ... RunOptFunc ) (* Workflow , error ) {
289289 inputBytes , err := json .Marshal (input )
290290
291291 if err != nil {
@@ -306,7 +306,7 @@ func (a *adminClientImpl) RunWorkflow(workflowName string, input interface{}, op
306306 }
307307 }
308308
309- res , err := a .client .TriggerWorkflow (a .ctx .newContext (context . Background () ), request )
309+ res , err := a .client .TriggerWorkflow (a .ctx .newContext (ctx ), request )
310310
311311 if err != nil {
312312 if status .Code (err ) == codes .AlreadyExists {
@@ -330,7 +330,7 @@ func (a *adminClientImpl) RunWorkflow(workflowName string, input interface{}, op
330330 }, nil
331331}
332332
333- func (a * adminClientImpl ) BulkRunWorkflow (workflows []* WorkflowRun ) ([]string , error ) {
333+ func (a * adminClientImpl ) BulkRunWorkflow (ctx context. Context , workflows []* WorkflowRun ) ([]string , error ) {
334334
335335 triggerWorkflowRequests := make ([]* admincontracts.TriggerWorkflowRequest , len (workflows ))
336336
@@ -358,7 +358,7 @@ func (a *adminClientImpl) BulkRunWorkflow(workflows []*WorkflowRun) ([]string, e
358358 Workflows : triggerWorkflowRequests ,
359359 }
360360
361- res , err := a .client .BulkTriggerWorkflow (a .ctx .newContext (context . Background () ), & r )
361+ res , err := a .client .BulkTriggerWorkflow (a .ctx .newContext (ctx ), & r )
362362
363363 if err != nil {
364364 return nil , fmt .Errorf ("could not bulk trigger workflows: %w" , err )
@@ -368,7 +368,7 @@ func (a *adminClientImpl) BulkRunWorkflow(workflows []*WorkflowRun) ([]string, e
368368
369369}
370370
371- func (a * adminClientImpl ) RunChildWorkflow (workflowName string , input interface {}, opts * ChildWorkflowOpts ) (string , error ) {
371+ func (a * adminClientImpl ) RunChildWorkflow (ctx context. Context , workflowName string , input interface {}, opts * ChildWorkflowOpts ) (string , error ) {
372372 inputBytes , err := json .Marshal (input )
373373
374374 if err != nil {
@@ -387,7 +387,7 @@ func (a *adminClientImpl) RunChildWorkflow(workflowName string, input interface{
387387
388388 metadata := string (metadataBytes )
389389
390- res , err := a .client .TriggerWorkflow (a .ctx .newContext (context . Background () ), & admincontracts.TriggerWorkflowRequest {
390+ res , err := a .client .TriggerWorkflow (a .ctx .newContext (ctx ), & admincontracts.TriggerWorkflowRequest {
391391 Name : workflowName ,
392392 Input : string (inputBytes ),
393393 ParentId : & opts .ParentId ,
@@ -419,7 +419,7 @@ type RunChildWorkflowsOpts struct {
419419 Opts * ChildWorkflowOpts
420420}
421421
422- func (a * adminClientImpl ) RunChildWorkflows (workflows []* RunChildWorkflowsOpts ) ([]string , error ) {
422+ func (a * adminClientImpl ) RunChildWorkflows (ctx context. Context , workflows []* RunChildWorkflowsOpts ) ([]string , error ) {
423423
424424 triggerWorkflowRequests := make ([]* admincontracts.TriggerWorkflowRequest , len (workflows ))
425425
@@ -463,7 +463,7 @@ func (a *adminClientImpl) RunChildWorkflows(workflows []*RunChildWorkflowsOpts)
463463
464464 }
465465
466- res , err := a .client .BulkTriggerWorkflow (a .ctx .newContext (context . Background () ), & admincontracts.BulkTriggerWorkflowRequest {
466+ res , err := a .client .BulkTriggerWorkflow (a .ctx .newContext (ctx ), & admincontracts.BulkTriggerWorkflowRequest {
467467 Workflows : triggerWorkflowRequests ,
468468 })
469469
@@ -475,7 +475,7 @@ func (a *adminClientImpl) RunChildWorkflows(workflows []*RunChildWorkflowsOpts)
475475 return res .WorkflowRunIds , nil
476476}
477477
478- func (a * adminClientImpl ) PutRateLimit (key string , opts * types.RateLimitOpts ) error {
478+ func (a * adminClientImpl ) PutRateLimit (ctx context. Context , key string , opts * types.RateLimitOpts ) error {
479479 if err := a .v .Validate (opts ); err != nil {
480480 return fmt .Errorf ("could not validate rate limit opts: %w" , err )
481481 }
@@ -496,7 +496,7 @@ func (a *adminClientImpl) PutRateLimit(key string, opts *types.RateLimitOpts) er
496496 putParams .Duration = admincontracts .RateLimitDuration_SECOND
497497 }
498498
499- _ , err := a .client .PutRateLimit (a .ctx .newContext (context . Background () ), putParams )
499+ _ , err := a .client .PutRateLimit (a .ctx .newContext (ctx ), putParams )
500500
501501 if err != nil {
502502 return fmt .Errorf ("could not upsert rate limit: %w" , err )
@@ -762,21 +762,21 @@ func (a *adminClientImpl) getAdditionalMetaBytes(opt *map[string]string) ([]byte
762762 return metadataBytes , nil
763763}
764764
765- func (h * adminClientImpl ) saveOrLoadListener () (* WorkflowRunsListener , error ) {
766- h .listenerMu .Lock ()
767- defer h .listenerMu .Unlock ()
765+ func (a * adminClientImpl ) saveOrLoadListener () (* WorkflowRunsListener , error ) {
766+ a .listenerMu .Lock ()
767+ defer a .listenerMu .Unlock ()
768768
769- if h .listener != nil {
770- return h .listener , nil
769+ if a .listener != nil {
770+ return a .listener , nil
771771 }
772772
773- listener , err := h .subscriber .SubscribeToWorkflowRunEvents (context .Background ())
773+ listener , err := a .subscriber .SubscribeToWorkflowRunEvents (context .Background ())
774774
775775 if err != nil {
776776 return nil , fmt .Errorf ("failed to subscribe to workflow run events: %w" , err )
777777 }
778778
779- h .listener = listener
779+ a .listener = listener
780780
781781 return listener , nil
782782}
0 commit comments