Skip to content

Commit

Permalink
- Changes in the Readme to reflect changes in the code
Browse files Browse the repository at this point in the history
- Reverting back changes in sdk/workflow/workflow.go to avoid breaking compatibility
  • Loading branch information
jmigueprieto committed Jul 9, 2024
1 parent c3413ef commit 7c0627d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ func main() {
}
// Till Here after registering the workflow
id, err := wf.StartWorkflowWithInput(map[string]string{
"name": "Gopher",
})
// Start the greetings workflow
id, err := wf.StartWorkflow(
&model.StartWorkflowRequest{
Name: "greetings",
Version: 1,
Input: map[string]string{
"name": "Gopher",
},
},
)
if err != nil {
log.Error(err.Error())
return
}
log.Info("Started workflow with Id: ", id)
// Get a channel to monitor the workflow execution -
Expand Down
14 changes: 11 additions & 3 deletions examples/hello_world/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
log "github.com/sirupsen/logrus"

"github.com/conductor-sdk/conductor-go/sdk/client"
"github.com/conductor-sdk/conductor-go/sdk/model"
"github.com/conductor-sdk/conductor-go/sdk/settings"

"github.com/conductor-sdk/conductor-go/sdk/worker"
Expand Down Expand Up @@ -59,9 +60,16 @@ func main() {
}
// Till Here after registering the workflow

id, err := wf.StartWorkflowWithInput(map[string]string{
"name": "Gopher",
})
// Start the greetings workflow
id, err := wf.StartWorkflow(
&model.StartWorkflowRequest{
Name: "greetings",
Version: 1,
Input: map[string]string{
"name": "Gopher",
},
},
)

if err != nil {
log.Error(err.Error())
Expand Down
16 changes: 8 additions & 8 deletions sdk/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ func (workflow *ConductorWorkflow) UnRegister() error {

// Start the workflow with specific input. The input struct MUST be serializable to JSON
// Returns the workflow Id that can be used to monitor and get the status of the workflow execution.
// version >= 2.0.0 - Workflow def is no longer sent with the request. The workflow MUST be registered before calling this function.
func (workflow *ConductorWorkflow) StartWorkflowWithInput(input interface{}) (workflowId string, err error) {
version := workflow.GetVersion()
return workflow.executor.StartWorkflow(
&model.StartWorkflowRequest{
Name: workflow.GetName(),
Version: version,
Input: getInputAsMap(input),
Name: workflow.GetName(),
Version: version,
Input: getInputAsMap(input),
WorkflowDef: workflow.ToWorkflowDef(),
},
)
}
Expand All @@ -189,14 +189,14 @@ func (workflow *ConductorWorkflow) StartWorkflow(startWorkflowRequest *model.Sta
// workflow completes or reaches the timeout (as specified on the server)
// The input struct MUST be serializable to JSON
// Returns the workflow output
// version >= 2.0.0 - Workflow def is no longer sent with the request. The workflow MUST be registered before calling this function.
func (workflow *ConductorWorkflow) ExecuteWorkflowWithInput(input interface{}, waitUntilTask string) (worfklowRun *model.WorkflowRun, err error) {
version := workflow.GetVersion()
return workflow.executor.ExecuteWorkflow(
&model.StartWorkflowRequest{
Name: workflow.GetName(),
Version: version,
Input: getInputAsMap(input),
Name: workflow.GetName(),
Version: version,
Input: getInputAsMap(input),
WorkflowDef: workflow.ToWorkflowDef(),
},
waitUntilTask,
)
Expand Down

0 comments on commit 7c0627d

Please sign in to comment.