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

fix(sdk-go): fixes input vars for reminder tasks #1184

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,27 @@ wf.scheduleReminderTask(userTask, delaySeconds, taskDefName, taskArg1, taskArg2)
</TabItem>
<TabItem value="go" label="Go">

GoLang support for user tasks coming soon.
```go
func QuickstartWorkflow(wf *littlehorse.WorkflowThread) {
// Declare an input variable and make it searchable
nameVar := wf.AddVariable("input-name", lhproto.VariableType_STR).Searchable()

// Execute a task and pass in the variable.
wf.Execute("greet", nameVar)

arg1 := "This is the first argument passed to the reminder task"
arg2 := "This is the second argument passed to the reminder task"
delaySeconds := 10 // wait 10 seconds after the task is assigned to schedule the reminder
reminderTaskDefName := "email-group"

userTaskOutput := wf.AssignUserTask("my-user-task", nil, "some-group")
wf.ScheduleReminderTask(userTaskOutput, delaySeconds, reminderTaskDefName, arg1, arg2)
}
```
</TabItem>
<TabItem value="python" label="Python">

Python docs for user tasks coming soon.

</TabItem>
</Tabs>
Expand Down
2 changes: 1 addition & 1 deletion sdk-go/littlehorse/wf_lib_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (t *WorkflowThread) reassignUserTaskOnDeadline(

func (t *WorkflowThread) scheduleReminderTask(
userTask *UserTaskOutput, delaySeconds interface{},
taskDefName string, args ...interface{},
taskDefName string, args []interface{},
) {
t.checkIfIsActive()

Expand Down
21 changes: 21 additions & 0 deletions sdk-go/littlehorse/wf_lib_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ func TestUserTaskWithOnCancellationExceptionName(t *testing.T) {
assert.Equal(t, "no-response", utNode.GetOnCancellationExceptionName().GetLiteralValue().GetStr())
}

func TestReminderTaskArgs(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a failing test before the change.

argForReminderTask := "some-arg-that-is-string"
wfObj := littlehorse.NewWorkflow(func(t *littlehorse.WorkflowThread) {
uto := t.AssignUserTask("some-user-task", "some-user", "some-group")

t.ScheduleReminderTask(uto, 20, "some-task", argForReminderTask)
}, "somem-workflow")

putWf, err := wfObj.Compile()
if err != nil {
t.Error(err)
}

entrypoint := putWf.ThreadSpecs[putWf.EntrypointThreadName]
node := entrypoint.Nodes["1-some-user-task-USER_TASK"]
utNode := node.GetUserTask()
assert.NotNil(t, utNode)
reminderAction := utNode.Actions[0]
assert.Equal(t, argForReminderTask, reminderAction.GetTask().Task.Variables[0].GetLiteralValue().GetStr())
}

func TestReminderTask(t *testing.T) {
wf := littlehorse.NewWorkflow(func(t *littlehorse.WorkflowThread) {
userVar := t.AddVariable("user", lhproto.VariableType_STR)
Expand Down
Loading