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

workflow example management missing components folder #569

Closed
sce9sc opened this issue Feb 1, 2024 · 12 comments
Closed

workflow example management missing components folder #569

sce9sc opened this issue Feb 1, 2024 · 12 comments
Labels
documentation Improvements or additions to documentation stale

Comments

@sce9sc
Copy link

sce9sc commented Feb 1, 2024

Components folder is missing from the Example in workflow/management

Also I find it difficult to undestand how can I call the sequence example in authoring from the management example.

Any help is much appreciated.

Thanks

@shubham1172 shubham1172 added the documentation Improvements or additions to documentation label Feb 1, 2024
@shubham1172
Copy link
Member

Thanks @sce9sc for finding this issue, we can reuse the same components from https://github.com/dapr/js-sdk/tree/main/examples/workflow/authoring/components (an actor state store is all that's required). Please feel free to send in a PR to fix it!

@sce9sc
Copy link
Author

sce9sc commented Feb 1, 2024

I will be very happy to contribute and fix any issues as well as creating more examples . Can you also explain to me why I cannot call the sequence workflow by changing the name like so

  const instanceId = await client.workflow.start("sequence");

What is the diffenece between DaprWorkflowClient and client.workflow ?

@shubham1172
Copy link
Member

Can you also explain to me why I cannot call the sequence workflow by changing the name like so

What error message do you get?

What is the diffenece between DaprWorkflowClient and client.workflow ?

In management code client.workflow, points to the IClientWorkflow in DaprClient. This can be used for management purpose, as defined by https://github.com/dapr/js-sdk/blob/main/src/interfaces/Client/IClientWorkflow.ts#L16. If you look at the implementation, it does so by making HTTP calls to the Dapr sidecar https://github.com/dapr/js-sdk/blob/main/src/implementation/Client/HTTPClient/workflow.ts.

DaprWorkflowClient does something similar, using gRPC https://github.com/dapr/js-sdk/blob/main/src/workflow/client/DaprWorkflowClient.ts#L27, by talking to the underlying TaskHub client.

Now that I think more about it, I think we should converge these to avoid confusion. What are your thoughts @DeepanshuA?

@sce9sc
Copy link
Author

sce9sc commented Feb 1, 2024

I get

Error starting workflow instance: {"error":"Bad Request","error_msg":"{\"errorCode\":\"ERR_WORKFLOW_COMPONENT_NOT_FOUND\",\"message\":\"workflow component 'dapr' does not exist\"}","status":400}```

I am not sure that I have configured it correctly though .

@sce9sc
Copy link
Author

sce9sc commented Feb 2, 2024

I managed to call the workflow using Post

POST http://localhost:50080/v1.0-beta1/workflows/dapr/sequence/start HTTP/1.1
content-type: application/json
apr-app-id: "activity-sequence-workflow"

@shubham1172
Copy link
Member

That should translate to the same call being made here

await this.client.executeWithApiVersion(

@sce9sc
Copy link
Author

sce9sc commented Feb 2, 2024

Yes you are correct . Calling directly the dapr instance is working using the above Post request . Spiining app a new instance with only the client and sending the same request using :

  const instanceId = await client.workflow.start("sequence");

does not . and I get

  "errorCode": "ERR_WORKFLOW_COMPONENT_NOT_FOUND",
  "message": "workflow component 'dapr' does not exist"

I 've even started the dapr sidecar with no client and send the same POST request to the new DAps instance and it did not work. Should it ?? I think I am missing something but I cant figure it out yet.

Should the 2 dapr instance be able to communicate with each other ? And by making a post to one it will call ther other that has the workflow?

@shubham1172
Copy link
Member

Both the applications (1) where you register the workflow and (2) where you manage the workflow with commands like start, purge, terminate, etc., should be talking to the same Dapr sidecar. This is an example where it is happening in the same application with .NET https://github.com/dapr/quickstarts/blob/master/workflows/csharp/sdk/order-processor/Program.cs#L54, you can also do it with multiple applications with a single Dapr instance.

@sce9sc
Copy link
Author

sce9sc commented Feb 2, 2024

From what you mentioned, in order to run a workflow we need to:
(1) have a Pod (or multi) with a dapr instance + app for registering a workflow together with the invocation capability that will trigger the workflow.
2) In order to run a workflow a different Pod will receive a request and make an invocation to the other Pod.

This means that Pod (1) will have an application that will have DaprServer instantiated together with DaprWorkflowClient and WorkflowRuntime and DaprClient if you want to have management also.
Or on the same pod run
One Dapr instance with 2 Apps ->

  1. with invocation( DaprServer, DaprWorkflowClient ) + workflow registration (WorkflowRuntime)
  2. with invocation( DaprServer, DaprClient ) for management

The examples are showing how a single Dapr instance together with an application that registers the flows and at the same time the same app runs the flows.

The net example is also showing that is using a single client to start and wait for the flow to finish, whereas the js-sdk there are 2 options .

    const id = await workflowClient.scheduleNewWorkflow(sequence);
  OR
    const id = await client.workflow.start("sequence");

Also as it shown the scheduleNewWorkflow needs TWorkflow and workflow.start needs only the name of the workflow.

@DeepanshuA
Copy link
Contributor

DeepanshuA commented Feb 6, 2024

Can you also explain to me why I cannot call the sequence workflow by changing the name like so

What error message do you get?

What is the diffenece between DaprWorkflowClient and client.workflow ?

In management code client.workflow, points to the IClientWorkflow in DaprClient. This can be used for management purpose, as defined by https://github.com/dapr/js-sdk/blob/main/src/interfaces/Client/IClientWorkflow.ts#L16. If you look at the implementation, it does so by making HTTP calls to the Dapr sidecar https://github.com/dapr/js-sdk/blob/main/src/implementation/Client/HTTPClient/workflow.ts.

DaprWorkflowClient does something similar, using gRPC https://github.com/dapr/js-sdk/blob/main/src/workflow/client/DaprWorkflowClient.ts#L27, by talking to the underlying TaskHub client.

Now that I think more about it, I think we should converge these to avoid confusion. What are your thoughts @DeepanshuA?

We can keep the components folderinsideworkflow, parallel to authoringandmanagement`.
Yeah, we can think to converge the two as well.
Or may be create a better documentation, where-in we explicitly specify what is needed for what and which one to use in which scenario.

@dapr-bot
Copy link
Collaborator

dapr-bot commented Apr 6, 2024

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

@dapr-bot dapr-bot added the stale label Apr 6, 2024
@dapr-bot
Copy link
Collaborator

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation stale
Projects
None yet
Development

No branches or pull requests

4 participants