From 82c576e63a3d87494849f6cb75cb751fd340e717 Mon Sep 17 00:00:00 2001 From: Kalyani Desai Date: Fri, 4 Oct 2024 17:54:06 +0530 Subject: [PATCH] SRVLOGIC-309-Data-Index-service: Added Data Index service section in the OSL docs --- ...less-logic-data-index-graphql-queries.adoc | 218 ++++++++++++++++++ .../serverless-logic-data-index.adoc | 20 +- 2 files changed, 236 insertions(+), 2 deletions(-) create mode 100644 modules/serverless-logic-data-index-graphql-queries.adoc diff --git a/modules/serverless-logic-data-index-graphql-queries.adoc b/modules/serverless-logic-data-index-graphql-queries.adoc new file mode 100644 index 000000000000..b7c748a6d432 --- /dev/null +++ b/modules/serverless-logic-data-index-graphql-queries.adoc @@ -0,0 +1,218 @@ +// Module included in the following assemblies: +// * serverless-logic/serverless-logic-supporting-services/serverless-logic-data-index + +:_mod-docs-content-type: REFERENCE +[id="serverless-logic-data-index-graphql-queries_{context}"] += GraphQL queries for workflow instances and jobs + +To retrieve data about workflow instances and jobs, you can use GraphQL queries. + +[id="serverless-logic-retrieve-data-workflow-instances_{context}"] +== Retrieve data from workflow instances + +You can retrieve information about a specific workflow instance by using the following query example: + +[source,text] +---- +{ + ProcessInstances { + id + processId + state + parentProcessInstanceId + rootProcessId + rootProcessInstanceId + variables + nodes { + id + name + type + } + } +} +---- + +[id="serverless-logic-retrieve-data-jobs_{context}"] +== Retrieve data from jobs + +You can retrieve data from a specific job instance by using the following query example: + +[source,text] +---- +{ + Jobs { + id + status + priority + processId + processInstanceId + executionCounter + } +} +---- + +[id="serverless-logic-filter-query-results_{context}"] +== Filter query results by using the where parameter + +You can filter query results by using the `where` parameter, allowing multiple combinations based on workflow attributes. + +.Example query to filter by state +[source,text] +---- +{ + ProcessInstances(where: {state: {equal: ACTIVE}}) { + id + processId + processName + start + state + variables + } +} +---- + +.Example query to filter by ID +[source,text] +---- +{ + ProcessInstances(where: {id: {equal: "d43a56b6-fb11-4066-b689-d70386b9a375"}}) { + id + processId + processName + start + state + variables + } +} +---- + +By default, filters are combined using the AND Operator. You can modify this behavior by combining filters with the AND or OR operators. + +.Example query to combine filters with the OR Operator +[source,text] +---- +{ + ProcessInstances(where: {or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}) { + id + processId + processName + start + end + state + } +} +---- + +.Example query to combine filters with the AND and OR Operators +[source,text] +---- +{ + ProcessInstances(where: {and: {processId: {equal: "travels"}, or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}}) { + id + processId + processName + start + end + state + } +} +---- + +Depending on the attribute type, you can use the following avaialable Operators: + +[cols=2*,options="header"] +|=== +|Attribute type +|Available Operators + +|String array +a| +* `contains`: String +* `containsAll`: Array of strings +* `containsAny`: Array of strings +* `isNull`: Boolean (true or false) + +|String +a| +* `in`: Array of strings +* `like`: String +* `isNull`: Boolean (true or false) +* `equal`: String + +|ID +a| +* `in`: Array of strings +* `isNull`: Boolean (true or false) +* `equal`: String + +|Boolean +a| +* `isNull`: Boolean (true or false) +* `equal`: Boolean (true or false) + +|Numeric +a| +* `in`: Array of integers +* `isNull`: Boolean +* `equal`: Integer +* `greaterThan`: Integer +* `greaterThanEqual`: Integer +* `lessThan`: Integer +* `lessThanEqual`: Integer +* `between`: Numeric range +* `from`: Integer +* `to`: Integer + +|Date +a| +* `isNull`: Boolean (true or false) +* `equal`: Date time +* `greaterThan`: Date time +* `greaterThanEqual`: Date time +* `lessThan`: Date time +* `lessThanEqual`: Date time +* `between`: Date range +* `from`: Date time +* `to`: Date time + +|=== + +[id="serverless-logic-sort-query-results_{context}"] +== Sort query results by using the orderBy parameter + +You can sort query results based on workflow attributes by using the `orderBy` parameter. You can also specify the sorting direction in an ascending (`ASC`) or a descending (`DESC`) order. Multiple attributes are applied in the order you specified. + +.Example query to sort by the start time in an `ASC` order +[source,text] +---- +{ + ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}) { + id + processId + processName + start + end + state + } +} +---- + +[id="serverless-logic-limits-offset-query-results_{context}"] +== Limit the number of results by using the pagination parameter + +You can control the number of returned results and specify an offset by using the `pagination` parameter. + +.Example query to limit results to 10, starting from offset 0 +[source,text] +---- +{ + ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}, pagination: {limit: 10, offset: 0}) { + id + processId + processName + start + end + state + } +} +---- \ No newline at end of file diff --git a/serverless-logic/serverless-logic-supporting-services/serverless-logic-data-index.adoc b/serverless-logic/serverless-logic-supporting-services/serverless-logic-data-index.adoc index c98d2935045d..e2368380c169 100644 --- a/serverless-logic/serverless-logic-supporting-services/serverless-logic-data-index.adoc +++ b/serverless-logic/serverless-logic-supporting-services/serverless-logic-data-index.adoc @@ -6,6 +6,22 @@ include::_attributes/common-attributes.adoc[] toc::[] -The Data Index service is a dedicated supporting service that stores the data related to the workflow instances and their associated jobs. This service provides a GraphQL endpoint allowing users to query and modify that data. +The Data Index service is a dedicated supporting service that stores the data related to the workflow instances and their associated jobs. This service provides a GraphQL endpoint allowing users to query that data. -//I will include more modules in smaller, incremental PRs to avoid having one large PR. Currently building the directory structure for the OSL content. \ No newline at end of file +The Data Index service processes data received through events, which can originate from any workflow or directly from the Job service. + +Data Index supports Apache Kafka or Knative Eventing to consume CloudEvents messages from workflows. It indexes and stores this event data in a database, making it accessible through GraphQL. These events provide detailed information about the workflow execution. The Data Index service is central to {ServerlessLogicProductName} search, insights, and management capabilities. + +The key features of the Data Index service are as follows: + +* A flexible data structure +* A distributable, cloud-ready format +* Message-based communication with workflows via Apache Kafka, Knative, and CloudEvents +* A powerful GraphQL-based querying API + +[NOTE] +==== +When you are using the {ServerlessOperatorName} to deploy workflows, you do not need to manually install or configure the Data Index service. The Operator automatically manages all the necessary configurations for each workflow to connect with it. +==== + +include::modules/serverless-logic-data-index-graphql-queries.adoc[leveloffset=+1] \ No newline at end of file