Skip to content

Commit

Permalink
Support for mocking nexus operations (#1666)
Browse files Browse the repository at this point in the history
* Support for mocking nexus operations

* address comments

* add tests

* add nexus events listeners

* add test for nexus listeners

* address comments

* add assert nexus calls methods

* address static checks

* Support mocking Nexus operation with operation reference (#1683)

* Support mocking Nexus operation with operation reference

* address comments

* address comments
  • Loading branch information
rodrigozhou authored Oct 28, 2024
1 parent 4afb587 commit 37d1775
Show file tree
Hide file tree
Showing 4 changed files with 1,002 additions and 52 deletions.
18 changes: 17 additions & 1 deletion internal/internal_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,22 @@ func (r *registry) getWorkflowDefinition(wt WorkflowType) (WorkflowDefinition, e
return newSyncWorkflowDefinition(executor), nil
}

func (r *registry) getNexusService(service string) *nexus.Service {
r.Lock()
defer r.Unlock()
return r.nexusServices[service]
}

func (r *registry) getRegisteredNexusServices() []*nexus.Service {
r.Lock()
defer r.Unlock()
result := make([]*nexus.Service, 0, len(r.nexusServices))
for _, s := range r.nexusServices {
result = append(result, s)
}
return result
}

// Validate function parameters.
func validateFnFormat(fnType reflect.Type, isWorkflow bool) error {
if fnType.Kind() != reflect.Func {
Expand Down Expand Up @@ -1058,7 +1074,7 @@ func (aw *AggregatedWorker) start() error {
return err
}
}
nexusServices := aw.registry.nexusServices
nexusServices := aw.registry.getRegisteredNexusServices()
if len(nexusServices) > 0 {
reg := nexus.NewServiceRegistry()
for _, service := range nexusServices {
Expand Down
Loading

0 comments on commit 37d1775

Please sign in to comment.