From f5d30756a615e0a0c1412252dcd015434a103cdc Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Thu, 7 May 2020 14:33:26 +0200 Subject: [PATCH] yaml-loader: add language doc --- docs/modules/languages/nav-languages.adoc | 1 + .../modules/languages/pages/yaml.adoc | 140 +++++++++--------- 2 files changed, 73 insertions(+), 68 deletions(-) rename camel-k-loader-yaml/README.adoc => docs/modules/languages/pages/yaml.adoc (94%) diff --git a/docs/modules/languages/nav-languages.adoc b/docs/modules/languages/nav-languages.adoc index 377ca336d..6fde60dfd 100644 --- a/docs/modules/languages/nav-languages.adoc +++ b/docs/modules/languages/nav-languages.adoc @@ -4,3 +4,4 @@ ** xref:languages:javascript.adoc[JavaScript] ** xref:languages:java.adoc[Java] ** xref:languages:xml.adoc[XML] +** xref:languages:yaml.adoc[YAML] diff --git a/camel-k-loader-yaml/README.adoc b/docs/modules/languages/pages/yaml.adoc similarity index 94% rename from camel-k-loader-yaml/README.adoc rename to docs/modules/languages/pages/yaml.adoc index 1956eba79..3a1333441 100644 --- a/camel-k-loader-yaml/README.adoc +++ b/docs/modules/languages/pages/yaml.adoc @@ -1,14 +1,15 @@ -= YAML DSL - -This artifact provides a YAML based DSL for Apache Camel and Apache Camel K. += Writing Integrations in YAML +[WARNING] +==== The YAML DSL is current in preview support level. +==== == Defining a route A route is a sequence of elements, or `steps`, defined as follow: -[source, yaml] +[source,yaml] ---- from: #<1> uri: "direct:start" @@ -36,7 +37,7 @@ As general rule each step provide all the parameters the related definition decl + Some steps such as `filter` and `split` have their own pipeline when an exchange matches the filter expression or for the items generated by the split expression, such pipeline can be defined by the `steps` field: + -[source, yaml] +[source,yaml] ---- filter: expression: @@ -55,7 +56,7 @@ if the `steps` field is omitted, then each subsequent step is considered part of + Some EIP such as `filter` and `split` supports the definition of an expression through the `expression` field: + -[source, yaml] +[source,yaml] .Explicit Expression field ---- filter: @@ -65,7 +66,7 @@ filter: + To make the DSL less verbose, the `expression` field can be omitted: + -[source, yaml] +[source,yaml] .Implicit Expression field ---- filter: @@ -74,7 +75,7 @@ filter: + In general expression can be defined inline like in the examples above but in case you need provide more information, you can 'unroll' the expression definition and configure any single parameter the expression defines. + -[source, yaml] +[source,yaml] .Full Expression definition ---- filter: @@ -87,7 +88,7 @@ filter: + Some EIP such as `set-body` and `marshal` supports the definition of data formats through the `data-format` field: + -[source, yaml] +[source,yaml] .Explicit Data Format field ---- set-body: @@ -98,7 +99,7 @@ set-body: + To make the DSL less verbose, the `data-format` field can be omitted: + -[source, yaml] +[source,yaml] .Implicit Data Format field ---- set-body: @@ -111,60 +112,6 @@ set-body: In case you want to use the data-format's default settings, you need to place an empty block as data format parameters, like `json: {}` ==== - -== Supported EIP - -- Aggregate -- Bean -- Choice -- Claim Check -- Convert Body -- Delay -- Dynamic Router -- Enrich -- Filter -- From -- Idempotent Consumer -- Load Balance -- Log -- Loop -- Marshal -- Multicast -- Pipeline -- PollEnrich -- Process -- Recipient List -- Remove Header -- Remove Headers -- Remove Property -- Remove Properties -- Resequence -- Rest DSL -- Rollback -- Routing Slip -- Sample -- Script -- Set Body -- Set Exchange Pattern -- Set Header -- Set Property -- Sort -- Split -- Step -- Stop -- Threads -- Throttle -- Throw Exception -- To -- To Dynamic -- Transform -- Try Catch Finally -- Unmarshal -- Validate -- Wire Tap - -The Try Catch Finally EIP currently only support specifying one `do-catch` clause. - == Extending the DSL The DSL is designed to be easily extended so you can provide your own step handler which is discovered at runtime using Camel's factory finder. @@ -181,11 +128,13 @@ class=com.acme.converter.MyConverter - create the step handler extending `org.apache.camel.k.loader.yaml.parser.ProcessorStepParser` + -[source, java] +[source,java] ---- package com.acme.converter.AcmeConverter -import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class AcmeConverter +import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser; + +public class AcmeConverter implements ProcessorStepParser { /** * @param context contains a references to the camel context and the current node as raw JsonNode @@ -216,8 +165,7 @@ import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class Ac Assuming the entry in the `META-INF/services/org/apache/camel/k/yaml` is named `acme` then you can use it from the YAML DSL like: - -[source, yaml] +[source,yaml] ---- from: uri: "direct:start" @@ -227,3 +175,59 @@ from: port: 8081 ---- +== Supported EIP + +- Aggregate +- Bean +- Choice +- Circuit Breaker +- Claim Check +- Convert Body +- Delay +- Dynamic Router +- Enrich +- Filter +- From +- Idempotent Consumer +- Load Balance +- Log +- Loop +- Marshal +- Multicast +- Pipeline +- PollEnrich +- Process +- Recipient List +- Remove Header +- Remove Headers +- Remove Property +- Remove Properties +- Resequence +- Rest DSL +- Rollback +- Routing Slip +- Saga +- Sample +- Script +- ServiceCall +- Set Body +- Set Exchange Pattern +- Set Header +- Set Property +- Sort +- Split +- Step +- Stop +- Threads +- Throttle +- Throw Exception +- To +- To Dynamic +- Transacted +- Transform +- Try Catch Finally +- Unmarshal +- Validate +- Wire Tap + +The Try Catch Finally EIP currently only support specifying one `do-catch` clause.