Skip to content

Commit

Permalink
[Fix #616] Adding dependency documentation to embedded
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Apr 5, 2024
1 parent 0d13994 commit 18bb3c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions serverlessworkflow/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ asciidoc:
kogito_examples_url: https://github.com/apache/incubator-kie-kogito-examples.git
kogito_apps_url: https://github.com/apache/incubator-kie-kogito-apps/tree/main
kogito_runtimes_url: https://github.com/apache/incubator-kie-kogito-runtimes/tree/main
kogito_runtimes_swf_url: https://github.com/apache/incubator-kie-kogito-runtimes/tree/main/kogito-serverless-workflow/
kogito_runtimes_swf_test_url: https://github.com/apache/incubator-kie-kogito-runtimes/tree/main/kogito-serverless-workflow/kogito-serverless-workflow-executor-tests/src/test/java/org/kie/kogito/serverless/workflow/executor
quarkus_cli_url: https://quarkus.io/guides/cli-tooling
spec_website_url: https://serverlessworkflow.io/
spec_doc_url: https://github.com/serverlessworkflow/specification/blob/0.8.x/specification.md
Expand Down Expand Up @@ -125,6 +127,15 @@ asciidoc:
golang_install_url: https://go.dev/doc/install
serverless_logic_web_tools_url: https://start.kubesmarts.org/
swf_executor_core_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-core
swf_fluent_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-fluent
swf_executor_rest_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-rest
swf_executor_python_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-python
swf_executor_grpc_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-grpc
swf_executor_events_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-kafka
swf_executor_service_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-executor-service
swf_executor_openapi_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-serverless-workflow-openapi-parser
rocksdb_addon_maven_repo_url: https://mvnrepository.com/artifact/org.kie.kogito/kogito-addons-persistence-rocksdb
rocksdb_url: https://rocksdb.org/
github_tokens_url: https://github.com/settings/tokens
openshift_developer_sandbox_url: https://developers.redhat.com/developer-sandbox
openshift_application_data_services_service_account_url: https://console.redhat.com/application-services/service-accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ The Camel route is responsible to produce the return value in a way that the wor

include::../../pages/_common-content/camel-valid-responses.adoc[]

[[con-func-python]
[[con-func-python]]
== Python custom function
{product_name} implements a custom function to execute embedded Python scripts and functions. See xref:use-cases/advanced-developer-use-cases/integrations/custom-functions-knative.adoc[Invoking Python from {product_name}]

Expand Down Expand Up @@ -535,6 +535,7 @@ kogito.sw.functions.greet.timeout=5000 <1>
----
<1> Time in milliseconds

[[con-func-rest]]
== Rest custom function

Serverless Workflow Specification defines the xref:service-orchestration/orchestration-of-openapi-based-services.adoc[OpenAPI function type], which is the preferred way to interact with existing REST servers.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
= Workflow embedded execution in Java
:compat-mode!:
// Metadata:
:description: Embedded execution of Workflows
:keywords: kogito, workflow, embedded, java, sonataflow



This guide uses a standard Java virtual machine and a small set of Maven dependencies to execute a link:{spec_doc_url}[CNCF Serverless Workflow] definition. Therefore, it is assumed you are fluent both in Java and Maven.
The workflow definition to be executed can be read from a `.json` or `.yaml` file or programmatically defined using the {product_name} fluent API.
Expand Down Expand Up @@ -54,7 +60,7 @@ Workflow execution result is {"greeting":"Hello World","mantra":"Serverless Work
[[embedded-fluent-quick-start]]
== Hello world (using fluent API)

Using the same Maven setup as in the previous section, you can programmatically generate that workflow definition rather than loading it from a file definition by using the link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API]
Adding link:{swf_fluent_maven_repo_url} dependency to the Maven setup in the previous section, you can programmatically generate that workflow definition rather than loading it from a file definition by using the link:{kogito_runtimes_url}/kogito-serverless-workflow/kogito-serverless-workflow-fluent/src/main/java/org/kie/kogito/serverless/workflow/fluent[fluent API]

Therefore, you can modify the previous example to generate the same output when it is executed, but rather than creating a `FileReader` that reads the `Workflow` object, we create the `Workflow` object using Java statements. The resulting modified main method is the following

Expand All @@ -79,6 +85,23 @@ Therefore, you can modify the previous example to generate the same output when
<7> Execute and print as in previous example


== Dependencies explanation

In order to keep the number of required dependencies as smaller as possible, embedded workflow follows a modular approach. For example, the link:{swf_executor_core_maven_repo_url}[core] dependency does not include the stuff to use link:{spec_doc_url}#using-functions-for-rpc-service-invocations[gRPC] or https://github.com/serverlessworkflow/specification/blob/0.8.x/specification.md#using-functions-for-restful-service-invocations[OpenAPI] function types, which needs to be included explicitly.

This is list of additional dependencies:

* link:{swf_executor_rest_maven_repo_url}[Rest]: Add if you use xref:core/custom-functions-support#con-func-rest[custom Rest] function type.
* link:{swf_executor_service_maven_repo_url}[Service]: Add if your use xref:core/custom-functions-support#con-func-java[custom Service] function type.
* link:{swf_executor_openapi_maven_repo_url}[OpenAPI]: Add if you use OpenAPI function type. See link:{kogito_runtimes_swf_test_url}/OpenAPIWorkflowApplicationTest.java[example].
* link:{swf_executor_grpc_maven_repo_url}[gRPC]: Add if you use gRPC function type. See link:{kogito_runtimes_swf_test_url}/RPCWorkflowApplicationTest.java[example].
* link:{swf_executor_python_maven_repo_url}[Python]: Add if you use xref:core/custom-functions-support#con-func-python[custom Python] function type. See link:{kogito_runtimes_swf_url}/kogito-serverless-workflow-executor-python/src/test/java/org/kie/kogito/serverless/workflow/executor/PythonFluentWorkflowApplicationTest.java[example].
* link:{swf_executor_events_maven_repo_url}[Events]: Add if you use Event or Callback state in your workflow. Only Kafka events are supported right now. See link:{kogito_runtimes_swf_url}/kogito-serverless-workflow-executor-kafka/src/test/java/org/kie/kogito/serverless/workflow/executor/WorkflowEventPublisherTest.java[Publisher] and link:{kogito_runtimes_swf_url}/kogito-serverless-workflow-executor-kafka/src/test/java/org/kie/kogito/serverless/workflow/executor/WorkflowEventSusbcriberTest.java[Subscriber] examples.

== Persistence support

You can include any {product_name} persistence add-on as dependency to enable persistence. However, within an embedded environment you usually do not have an external db, therefore, if you want to preserve the state of active nodes once the JVM is closed, we recommend using link:{rocksdb_url}[rocksdb] embedded database. You do that by adding the link:{rocksdb_addon_maven_repo_url}[rocksdb add-on] dependency. See link:{kogito_runtimes_swf_test_url}/PersistentApplicationTest.java[example]

== Further reading

You can find additional and commented examples of fluent API usage (including jq expression evaluation and orchestration of rest services) link:{kogito_sw_examples_url}/sonataflow-fluent[here]
Expand Down

0 comments on commit 18bb3c7

Please sign in to comment.