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 Implementation - Continues... #880

Merged
merged 82 commits into from
Sep 13, 2023
Merged

Conversation

macromania
Copy link
Contributor

@macromania macromania commented Jun 21, 2023

Description

This PR continues the Workflow implementation on top of #857. This PR will be rebased once #857 is merged to main. So, about 20 of the files in this PR would be already reviewed and merged to main 👀

☢️ Due to missing commit sign offs in our setup, I had to rebase and sign-off the commits again. The commit history seems bigger than expected due to that. No work is lost and only commit messages are amended. 🙏🏼

In the meantime, please feel free to review and provide feedback 😅

As seen from the implementation, it involves abstraction of Durable Task Framework in most places. This means some of the functionality are not provided in this PR as they also lack implementation support at Durable Task Framework.

Management API

  • raiseEvent
  • getInstanceMetadata
  • waitForInstanceStart
  • waitForInstanceCompletion
  • createTaskHub
  • deleteTaskHub
  • purgeInstance

As mentioned in microsoft/durabletask-java#142, queryInstances and purgeInstances are not supported due to limitations at Dapr datastore.

Authoring API

  • getName
  • getInput
  • getInstanceId
  • getCurrentInstant
  • getIsReplaying
  • allOf
  • anyOf
  • createTimer
  • complete
  • callActivity
  • continueAsNew
  • sendEvent
  • callSubOrchestrator
  • waitForExternalEvent

Testing

We have provided unit test coverage with mocks for all the SDK methods. Also, we have expanded the example provided in #857 by adding all of the Authoring and Management API calls. We used the example as a mean to test the integrity of the code and also understand if the developer experience is satisfactory.

When the example is run, following output is expected from the DemoWorkflow.

INFO[0006] 834a10a5-6fca-4615-98f2-457b9b29a27a: starting new 'io.dapr.examples.workflows.DemoWorkflow' instance with ID = '834a10a5-6fca-4615-98f2-457b9b29a27a'.  app_id=demoworkflowworker instance=Macbook scope=dapr.runtime.wfengine type=log ver=1.11.0
== APP == 2023-06-20 10:27:01,258 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Starting Workflow: io.dapr.examples.workflows.DemoWorkflow
== APP == 2023-06-20 10:27:01,260 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Instance ID: 834a10a5-6fca-4615-98f2-457b9b29a27a
== APP == 2023-06-20 10:27:01,260 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Current Orchestration Time: 2023-06-20T09:27:01.232Z
== APP == 2023-06-20 10:27:01,260 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Waiting for event: 'TimedOutEvent'...
== APP == 2023-06-20 10:27:11,010 {HH:mm:ss.SSS} [main] WARN  i.d.w.runtime.WorkflowContext - Timed out
== APP == 2023-06-20 10:27:11,010 {HH:mm:ss.SSS} [main] WARN  i.d.w.runtime.WorkflowContext - Timeout of PT10S expired while waiting for an event named 'TimedOutEvent' (ID = 0).
== APP == 2023-06-20 10:27:11,010 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Waiting for event: 'TestEvent'...
== APP == 2023-06-20 10:27:11,010 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Received TestEvent
== APP == 2023-06-20 10:27:11,010 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Parallel Execution - Waiting for all tasks to finish...
== APP == 2023-06-20 10:27:11,024 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - finished task: TestEvent 1 Payload
== APP == 2023-06-20 10:27:11,024 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - finished task: TestEvent 2 Payload
== APP == 2023-06-20 10:27:11,024 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - finished task: TestEvent 3 Payload
== APP == 2023-06-20 10:27:11,024 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - All tasks finished!
== APP == 2023-06-20 10:27:11,024 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Parallel Execution - Waiting for any task to finish...
== APP == 2023-06-20 10:27:11,025 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - One of the tasks finished!
== APP == 2023-06-20 10:27:11,025 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Calling Activity...
== APP == 2023-06-20 10:27:11,086 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Starting Activity: io.dapr.examples.workflows.DemoWorkflowActivity
== APP == 2023-06-20 10:27:11,103 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Message Received from input: Hello Activity!
== APP == 2023-06-20 10:27:11,103 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Sending message to output: Hello Activity! World!, from Activity
== APP == 2023-06-20 10:27:11,103 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Sleeping for 5 seconds to simulate long running operation...
== APP == 2023-06-20 10:27:16,108 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Activity finished
== APP == 2023-06-20 10:27:16,109 {HH:mm:ss.SSS} [main] INFO  i.d.e.workflows.DemoWorkflowActivity - Activity returned: io.dapr.examples.workflows.DemoActivityOutput@69e153c5
== APP == 2023-06-20 10:27:16,162 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Activity returned: io.dapr.examples.workflows.DemoActivityOutput@1ca3b418
== APP == 2023-06-20 10:27:16,162 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Activity returned: Hello Activity! World!, from Activity
== APP == 2023-06-20 10:27:16,162 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Activity returned: Hello Activity!
== APP == 2023-06-20 10:27:16,162 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Waiting for event: 'RestartEvent'...
== APP == 2023-06-20 10:27:26,010 {HH:mm:ss.SSS} [main] WARN  i.d.w.runtime.WorkflowContext - Restart Timed out
== APP == 2023-06-20 10:27:26,011 {HH:mm:ss.SSS} [main] WARN  i.d.w.runtime.WorkflowContext - Timeout of PT10S expired while waiting for an event named 'RestartEvent' (ID = 13).
== APP == 2023-06-20 10:27:26,011 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Calling ChildWorkflow...
INFO[0031] a2ff610e-009f-4bcb-af52-2b35241e980e: starting new 'io.dapr.examples.workflows.DemoSubWorkflow' instance with ID = 'a2ff610e-009f-4bcb-af52-2b35241e980e'.  app_id=demoworkflowworker instance=Macbook scope=dapr.runtime.wfengine type=log ver=1.11.0
== APP == 2023-06-20 10:27:26,046 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Started: io.dapr.examples.workflows.DemoSubWorkflow
== APP == 2023-06-20 10:27:26,047 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Instance ID: a2ff610e-009f-4bcb-af52-2b35241e980e
== APP == 2023-06-20 10:27:26,047 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Current Time: 2023-06-20T09:27:26.044Z
== APP == 2023-06-20 10:27:26,047 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Input: Hello ChildWorkflow!
== APP == 2023-06-20 10:27:26,047 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> Completed
INFO[0031] a2ff610e-009f-4bcb-af52-2b35241e980e: 'io.dapr.examples.workflows.DemoSubWorkflow' completed with a COMPLETED status.  app_id=demoworkflowworker instance=MSFT-Macbook scope=dapr.runtime.wfengine type=log ver=1.11.0
== APP == 2023-06-20 10:27:26,063 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Child-Workflow> returned: result: Hello ChildWorkflow!
== APP == 2023-06-20 10:27:26,064 {HH:mm:ss.SSS} [main] INFO  i.d.w.runtime.WorkflowContext - Workflow finished
INFO[0031] 834a10a5-6fca-4615-98f2-457b9b29a27a: 'io.dapr.examples.workflows.DemoWorkflow' completed with a COMPLETED status.  app_id=demoworkflowworker instance=Macbook scope=dapr.runtime.wfengine type=log ver=1.11.0

The above logs show that:

  1. Workflow starts
  2. Wait for an event called TimedOutEvent and eventually time out
  3. Wait for an event called TestEvent and show the event is received
  4. Parallel execution of tasks using allOf
  5. Parallel execution of tasks using anyOf
  6. Starting an Activity
  7. Executing the Activity
  8. Parsing the result of the Activity
  9. Starting a ChildWorkflow

Also, when you run the example to the end, you will be showcased:

  1. purgeInstance
  2. terminate
  3. restart

Issue reference

#839

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

LionTao and others added 30 commits June 21, 2023 12:34
Signed-off-by: LionTao <taojiachun980831@163.com>

Signed-off-by: LionTao <taojiachun980831@163.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
* Bump from spring boot 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <champel@gmail.com>
(cherry picked from commit 9152c91)

* Ensure old versions of spring boot are still compatible

Signed-off-by: Sergio <champel@gmail.com>

---------

Signed-off-by: champel <champel@gmail.com>
Signed-off-by: Sergio <champel@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
* Bump from reactor 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <champel@gmail.com>

* Simplification

Signed-off-by: Sergio <champel@gmail.com>

---------

Signed-off-by: Sergio <champel@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
* add grpc subscriber

Signed-off-by: MregXN <mregxn@gmail.com>

* modify README.md

Signed-off-by: MregXN <mregxn@gmail.com>

* modify README.md in examples

Signed-off-by: MregXN <mregxn@gmail.com>

* Modify DaprApplication to support examples where protocol is not specified.

Signed-off-by: MregXN <mregxn@gmail.com>

* modify formatter to pass checkstyle

Signed-off-by: MregXN <mregxn@gmail.com>

* Update springboot to latest minor.patch version. (dapr#826)

Signed-off-by: MregXN <mregxn@gmail.com>

* Use runtime 1.10.0-rc.X and CLI 1.10.0-rc.X (dapr#827)

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* Upgrade the version to 1.9.0-SNAPSHOT (dapr#829)

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* Generate updated javadocs for 1.8.0 (dapr#836)

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* Update Dapr runtime and CLI to 1.10. (dapr#837)

Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* Inject autoconfiguration in the Spring Boot 3 style (dapr#831)

* Bump from spring boot 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <champel@gmail.com>
(cherry picked from commit 9152c91)

* Ensure old versions of spring boot are still compatible

Signed-off-by: Sergio <champel@gmail.com>

---------

Signed-off-by: champel <champel@gmail.com>
Signed-off-by: Sergio <champel@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* Bump from reactor 2.3.5.RELEASE to 2.7.8 (dapr#830)

* Bump from reactor 2.3.5.RELEASE to 2.7.8

Signed-off-by: Sergio <champel@gmail.com>

* Simplification

Signed-off-by: Sergio <champel@gmail.com>

---------

Signed-off-by: Sergio <champel@gmail.com>
Signed-off-by: MregXN <mregxn@gmail.com>

* rerun checks

Signed-off-by: MregXN <mregxn@gmail.com>

* modify the way of grpc server starts

Signed-off-by: MregXN <mregxn@gmail.com>

* modify README

Signed-off-by: MregXN <mregxn@gmail.com>

* Update pom.xml

Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com>

---------

Signed-off-by: MregXN <mregxn@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: champel <champel@gmail.com>
Signed-off-by: Sergio <champel@gmail.com>
Signed-off-by: MregXN <46479059+MregXN@users.noreply.github.com>
Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
Co-authored-by: champel <champel@gmail.com>
Co-authored-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.1 to 3.1.4.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v3.1.1...v3.1.4)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
* prepare before testing

* Update tests

* fix checkstyle

---------

Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Artur Souza <asouza.pro@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <billderusha@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Hannah Kennedy <hakenned@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Hannah Kennedy <hakenned@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Bill DeRusha <444835+bderusha@users.noreply.github.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
* addiny getInstanceMetadata, waitForInstanceStart and waitForInstanceCompletion implementation
---------

Co-authored-by: aymanmahmoud_microsoft <aymanmahmoud@microsoft.com>
Signed-off-by: Aymand Mahmoud <aymanmahmoud@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Co-authored-by: Julio Rezende <jsilvarezend@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Julio Rezende <jsilvarezend@microsoft.com>
Co-authored-by: Julio Rezende <jsilvarezend@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Julio Rezende <jsilvarezend@microsoft.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
@macromania
Copy link
Contributor Author

@skyao I believe I have covered all the comments in my latest commits.

@macromania
Copy link
Contributor Author

Another review comment, let me write down it here so that we can discuss it.

Let's design the sub-packages in workflow.

I found that in current implementation of workflow, we have introduced a lot of concepts and their implementation code for :

  • workflow
  • workflow client
  • workflow runtime / workflow runtime status
  • workflow instance / workflow instance status
  • workflow failure
  • workflow activity /workflow activity context
  • workflow context
  • workflow stub

Now we have two sub packages:

  1. client: includes workflow client / workflow failure / workflow instance status
  2. runtime: includes workflow runtime and workflow activity /workflow activity context

I suggest that we should review these concepts and the sub-packages.

Another question is that: for the new comers who is trying to use dapr workflow at the first time, how can we let him understand above concepts quickly?

Fair points @skyao 👍🏼

The concept of workflow and running activities as a workflow is not a common paradigm that we could see in most applications. However, when we consider the choreography vs orchestration discussion in microservices architecture, workflows are closer to orchestration.

An orchestrator by design should be able to provide an instance of its workflow running. Also, it should provide a client for an external entities (another program, the developer etc.) to operate on the orchestration. These two concerns are covered by workflow client, workflow instance and workflow runtime.

On the other hand, an orchestrator needs tasks to complete the business objective. In our case, these are covered by workflow activity and workflow activity context.

In this context, someone looking at dapr workflows for the first time needs a clear understanding of which path they are choosing orchestration over choreography. The example project provides the implementation details but the documentation should touch the above concepts in detail.

Copy link
Member

@skyao skyao left a comment

Choose a reason for hiding this comment

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

Great work! Thank for your contribution @macromania !

I have competed my review and confirmed that all my comments have been updated.

@artursouza @mukundansundar please help to have a look at this PR and if OK please help to merge it.

@skyao
Copy link
Member

skyao commented Aug 29, 2023

@artursouza @mukundansundar please help to merge this PR.

@skyao
Copy link
Member

skyao commented Aug 31, 2023

I need to confirm the design of dapr workflow java sdk:

our dapr workflow java sdk will access backend of durable task directly and bypass dapr's sidecar (including dapr api layer and all workflow components).

To confirm this design, I list a lot of our implementation:

  • in dapr/dapr repo, workflow api is added in dapr/proto/runtime/v1/dapr.proto
service Dapr {
  // Starts a new instance of a workflow
  rpc StartWorkflowAlpha1 (StartWorkflowRequest) returns (StartWorkflowResponse) {}

  // Gets details about a started workflow instance
  rpc GetWorkflowAlpha1 (GetWorkflowRequest) returns (GetWorkflowResponse) {}

  // Purge Workflow
  rpc PurgeWorkflowAlpha1 (PurgeWorkflowRequest) returns (google.protobuf.Empty) {}

  // Terminates a running workflow instance
  rpc TerminateWorkflowAlpha1 (TerminateWorkflowRequest) returns (google.protobuf.Empty) {}

  // Pauses a running workflow instance
  rpc PauseWorkflowAlpha1 (PauseWorkflowRequest) returns (google.protobuf.Empty) {}

  // Resumes a paused workflow instance
  rpc ResumeWorkflowAlpha1 (ResumeWorkflowRequest) returns (google.protobuf.Empty) {}

  // Raise an event to a running workflow instance
  rpc RaiseEventWorkflowAlpha1 (RaiseEventWorkflowRequest) returns (google.protobuf.Empty) {}
}
  • and also in dapr/dapr repo, we have updated HTTP API and gRPC API to support above workflow API

  • in dapr/components-contrib rep, we also added the support for workflow and provided a workflow component implementation for temporal.

  • BUT, in dapr/java sdk of current two workflow PRs, we used the java sdk of DurableTask directly:

import com.microsoft.durabletask.DurableTaskClient;

public class DaprWorkflowClient implements AutoCloseable {

  DurableTaskClient innerClient;
  ManagedChannel grpcChannel;

 public <T extends Workflow> String scheduleNewWorkflow(Class<T> clazz) {
    return this.innerClient.scheduleNewOrchestrationInstance(clazz.getCanonicalName());
  }

And the method of dapr workflow api like StartWorkflowAlpha1/GetWorkflowAlpha1 are never called in the two PR.

class DaprWorkflowClient:
    """Defines client operations for managing Dapr Workflow instances.

       This is an alternative to the general purpose Dapr client. It uses a gRPC connection to send
       commands directly to the workflow engine, bypassing the Dapr API layer.

       This client is intended to be used by workflow application, not by general purpose
       application.
    """

So, with current design of java workflow sdk, we only provides support for microsoft durabletask and the implementation is hard code.

@DeepanshuA
Copy link
Contributor

And the method of dapr workflow api like StartWorkflowAlpha1/GetWorkflowAlpha1 are never called in the two PR.

Please refer this PR for python-sdk, where management APIs are used: dapr/python-sdk#554

This PR for dotnet: dapr/dotnet-sdk#1003

sdk-workflows/pom.xml Show resolved Hide resolved
* data provided to it by the orchestrator.
* @return any serializable value to be returned to the calling orchestrator.
*/
Object run(WorkflowActivityContext ctx);
Copy link
Member

Choose a reason for hiding this comment

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

Use generic and the serializer interface to return the actual object. See how it is done for DaprClient

Copy link
Member

Choose a reason for hiding this comment

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

@artursouza this run() method defined in WorkflowActivity doesn't have a input parameter, we need to call ctx.getInput() to get the input, like this:

    public Object run(WorkflowActivityContext ctx) {
        OrderPayload order = ctx.getInput(OrderPayload.class);
        logger.info("Requesting approval for order: {}", order);

        return ApprovalResult.Approved;
    }

I suggest to move this input parameter from ctx to run() method:

public interface WorkflowActivity<Input, Output>{
  Output run(WorkflowActivityContext ctx, Input input);
}

Copy link
Member

Choose a reason for hiding this comment

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

Exactly. Also, use TypeRef from the main SDK. See how we do it for Actors and state store.

Copy link
Member

Choose a reason for hiding this comment

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

Please, make this as a separate PR. I will make the other changes and merge this.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have permissions to edit files in this PR. Please, address the other comments so I can merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just pushed the changes, thanks for your review @artursouza 👍🏼

Signed-off-by: Mahmut Canga <cangamahmut@gmail.com>
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage: 73.38% and project coverage change: -0.05% ⚠️

Comparison is base (cf8040d) 76.94% compared to head (65b3354) 76.90%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #880      +/-   ##
============================================
- Coverage     76.94%   76.90%   -0.05%     
- Complexity     1326     1395      +69     
============================================
  Files           126      132       +6     
  Lines          4091     4230     +139     
  Branches        484      493       +9     
============================================
+ Hits           3148     3253     +105     
- Misses          696      720      +24     
- Partials        247      257      +10     
Files Changed Coverage Δ
...c/main/java/io/dapr/workflows/WorkflowContext.java 41.17% <41.17%> (ø)
...ava/io/dapr/workflows/runtime/ActivityWrapper.java 64.70% <64.70%> (ø)
...a/io/dapr/workflows/client/DaprWorkflowClient.java 80.95% <68.42%> (-10.36%) ⬇️
...apr/workflows/runtime/WorkflowActivityContext.java 71.42% <71.42%> (ø)
...ava/io/dapr/workflows/DaprWorkflowContextImpl.java 87.50% <78.57%> (-12.50%) ⬇️
.../dapr/workflows/runtime/WorkflowRuntimeStatus.java 79.41% <79.41%> (ø)
.../dapr/workflows/client/WorkflowFailureDetails.java 85.71% <85.71%> (ø)
.../dapr/workflows/client/WorkflowInstanceStatus.java 90.90% <90.90%> (ø)
...dapr/workflows/runtime/WorkflowRuntimeBuilder.java 84.61% <100.00%> (+39.16%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mukundansundar mukundansundar merged commit 056aed4 into dapr:master Sep 13, 2023
15 of 17 checks passed
@mukundansundar mukundansundar added this to the v1.10 milestone Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.