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

Added Throttle Action Kamelet #572

Merged
merged 7 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions docs/modules/ROOT/assets/images/kamelets/throttle-action.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
* xref:ROOT:string-template-action.adoc[image:kamelets/string-template-action.svg[] String Template Action]
* xref:ROOT:telegram-sink.adoc[image:kamelets/telegram-sink.svg[] Telegram Sink]
* xref:ROOT:telegram-source.adoc[image:kamelets/telegram-source.svg[] Telegram Source]
* xref:ROOT:throttle-action.adoc[image:kamelets/throttle-action.svg[] Throttle Action]
* xref:ROOT:timer-source.adoc[image:kamelets/timer-source.svg[] Timer Source]
* xref:ROOT:timestamp-router-action.adoc[image:kamelets/timestamp-router-action.svg[] Timestamp Router Action]
* xref:ROOT:topic-name-matches-filter-action.adoc[image:kamelets/topic-name-matches-filter-action.svg[] Kafka Topic Name Matches Filter Action]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/mariadb-sink.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Send data to a MariaDB Database.

In you KameletBinding file you'll need to explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies

- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/mariadb-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Query data from a MariaDB Database.

In you KameletBinding file you'll need to explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the MariaDB Server driver dependency in spec->integration->dependencies

- "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/mysql-sink.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Send data to a MySQL Database.

In you KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies

- "mvn:mysql:mysql-connector-java:<version>"

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/mysql-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Query data from a MySQL Database.

In you KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies

- "mvn:mysql:mysql-connector-java:<version>"

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/sqlserver-sink.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Send data to a Microsoft SQL Server Database.

In you KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies

- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/sqlserver-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Query data from a Microsoft SQL Server Database.

In you KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies
In your KameletBinding file you'll need to explicitly declare the SQL Server driver dependency in spec->integration->dependencies

- "mvn:com.microsoft.sqlserver:mssql-jdbc:<version>"

Expand Down
161 changes: 161 additions & 0 deletions docs/modules/ROOT/pages/throttle-action.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT

= image:kamelets/throttle-action.svg[] Throttle Action

*Provided by: "Apache Software Foundation"*

*Support Level for this Kamelet is: "Preview"*

The Throttl action allows to ensure that a specific sink does not get overloaded.

== Configuration Options

The following table summarizes the configuration options available for the `throttle-action` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *messages {empty}* *| Messages Number| The number of messages to send in the time period set| int| | `10`
| timePeriod| Time Period| Sets the time period during which the maximum request count is valid for, in milliseconds| string| `"1000"`|
|===

NOTE: Fields marked with an asterisk ({empty}*) are mandatory.


== Dependencies

At runtime, the `throttle-action` Kamelet relies upon the presence of the following dependencies:

- camel:core
- camel:kamelet

== Usage

This section describes how you can use the `throttle-action`.

=== Knative Action

You can use the `throttle-action` Kamelet as an intermediate step in a Knative binding.

.throttle-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: throttle-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: throttle-action
properties:
messages: 10
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel

----

==== *Prerequisite*

You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

==== *Procedure for using the cluster CLI*

. Save the `throttle-action-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the action by using the following command:
+
[source,shell]
----
kubectl apply -f throttle-action-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the action by using the following command:

[source,shell]
----
kamel bind timer-source?message=Hello --step throttle-action -p step-0.messages=10 channel:mychannel
----

This command creates the KameletBinding in the current namespace on the cluster.

=== Kafka Action

You can use the `throttle-action` Kamelet as an intermediate step in a Kafka binding.

.throttle-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: throttle-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: throttle-action
properties:
messages: 10
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic

----

==== *Prerequisites*

* You've installed https://strimzi.io/[Strimzi].
* You've created a topic named `my-topic` in the current namespace.
* You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

==== *Procedure for using the cluster CLI*

. Save the `throttle-action-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the action by using the following command:
+
[source,shell]
----
kubectl apply -f throttle-action-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the action by using the following command:

[source,shell]
----
kamel bind timer-source?message=Hello --step throttle-action -p step-0.messages=10 kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
----

This command creates the KameletBinding in the current namespace on the cluster.

== Kamelet source file

https://github.com/apache/camel-kamelets/blob/main/throttle-action.kamelet.yaml

// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: throttle-action
labels:
camel.apache.org/kamelet.type: "action"
annotations:
camel.apache.org/kamelet.support.level: "Preview"
camel.apache.org/catalog.version: "main-SNAPSHOT"
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9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I2LC01MCA0MSwtOTggbCAxODMsLTI4IHEgMTMsLTIgMjEsLTEyLjUgOCwtMTAuNSA4LC0yMy41IHoiCiAgICAgICBpZD0icGF0aDMwMjkiCiAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgc3R5bGU9ImZpbGw6Y3VycmVudENvbG9yIiAvPgogIDwvZz4KPC9zdmc+Cg=="
camel.apache.org/provider: "Apache Software Foundation"
camel.apache.org/kamelet.group: "Actions"
spec:
definition:
title: "Throttle Action"
description: "The Throttl action allows to ensure that a specific sink does not get overloaded."
required:
- messages
properties:
messages:
title: Messages Number
description: The number of messages to send in the time period set
type: int
example: 10
timePeriod:
title: Time Period
description: Sets the time period during which the maximum request count is valid for, in milliseconds
type: string
default: "1000"
type: object
dependencies:
- "camel:core"
- "camel:kamelet"
flow:
from:
uri: kamelet:source
steps:
- throttle:
constant: "{{messages}}"
timePeriodMillis: "{{timePeriod}}"
24 changes: 24 additions & 0 deletions templates/bindings/camel-k/throttle-action-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: throttle-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: throttle-action
properties:
messages: 10
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
13 changes: 13 additions & 0 deletions templates/bindings/core/throttle-action-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 1000
message: "{ \"foo\": \"John\"}"
steps:
- to:
uri: "kamelet:throttle-action"
parameters:
messages: 10
- to:
uri: "log:info"
Loading