Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-677: support task creation with variadic args #755

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

Higan
Copy link
Contributor

@Higan Higan commented Jul 11, 2024

What does this do?

This pull request implements variadic args support for task creation

Which issue(s) does this PR fix/relate to?

Resolves #677

List any changes that modify/break current functionality

Have you included tests for your changes?

I have added several cases in scheduler_test.go based on my changes

Did you document any new/modified functionality?

  • Updated scheduler_test.go

Notes

scheduler.go Outdated
@@ -535,6 +535,47 @@ func (s *scheduler) NewJob(jobDefinition JobDefinition, task Task, options ...Jo
return s.addOrUpdateJob(uuid.Nil, jobDefinition, task, options)
}

func (s *scheduler) verifyParameterType(taskFunc reflect.Value, tsk task) error {
isVariadic := taskFunc.Type().IsVariadic()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 epic, i was poking around the other day but didn't notice this IsVariadic method

},
{
"all good no arguments passed in - variadic",
NewTask(func(args ...interface{}) {}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a test case with multiple argument types where the last one is variadic?

something like

NewTask(func(arg int, args ...string) {}, 1, "one", "two")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure this was neglected in my previous commit. And it's added now in this PR. Please have a look.

@JohnRoesler JohnRoesler merged commit 2c08083 into go-co-op:v2 Jul 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Cannot create job with task with variadic args
2 participants