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

Add protobuf serdes #331

Merged
merged 3 commits into from
Jun 7, 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
* xref:ROOT:openai-classification-action.adoc[image:kamelets/openai-classification-action.svg[] OpenAI Classification Action]
* xref:ROOT:openai-completion-action.adoc[image:kamelets/openai-completion-action.svg[] OpenAI Completion Action]
* xref:ROOT:pdf-action.adoc[image:kamelets/pdf-action.svg[] PDF Action]
* xref:ROOT:protobuf-deserialize-action.adoc[image:kamelets/protobuf-deserialize-action.svg[] Protobuf Deserialize Action]
* xref:ROOT:protobuf-serialize-action.adoc[image:kamelets/protobuf-serialize-action.svg[] Protobuf Serialize Action]
* xref:ROOT:rabbitmq-source.adoc[image:kamelets/rabbitmq-source.svg[] RabbitMQ Source]
* xref:ROOT:regex-router-action.adoc[image:kamelets/regex-router-action.svg[] Regex Router Action]
* xref:ROOT:replace-field-action.adoc[image:kamelets/replace-field-action.svg[] Replace Field Action]
Expand Down
69 changes: 69 additions & 0 deletions docs/modules/ROOT/pages/protobuf-deserialize-action.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/protobuf-deserialize-action.svg[] Protobuf Deserialize Action

*Provided by: "Apache Software Foundation"*

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

Deserialize payload to Protobuf

== Configuration Options

The following table summarizes the configuration options available for the `protobuf-deserialize-action` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *schema {empty}* *| Schema| The Protobuf schema to use during serialization (as single-line)| string| | `"message Person { required string first = 1; required string last = 2; }"`
|===

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

== Usage

This section summarizes how the `protobuf-deserialize-action` can be used in various contexts.

=== Knative Action

The `protobuf-deserialize-action` Kamelet can be used as intermediate step in a binding.

.protobuf-deserialize-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: protobuf-deserialize-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: protobuf-deserialize-action
properties:
schema: "message Person { required string first = 1; required string last = 2; }"
sink:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel

----

Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `protobuf-deserialize-action-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the action using the following command:

[source,shell]
----
kubectl apply -f protobuf-deserialize-action-binding.yaml
----
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
69 changes: 69 additions & 0 deletions docs/modules/ROOT/pages/protobuf-serialize-action.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/protobuf-serialize-action.svg[] Protobuf Serialize Action

*Provided by: "Apache Software Foundation"*

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

Serialize payload to Protobuf

== Configuration Options

The following table summarizes the configuration options available for the `protobuf-serialize-action` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *schema {empty}* *| Schema| The Protobuf schema to use during serialization (as single-line)| string| | `"message Person { required string first = 1; required string last = 2; }"`
|===

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

== Usage

This section summarizes how the `protobuf-serialize-action` can be used in various contexts.

=== Knative Action

The `protobuf-serialize-action` Kamelet can be used as intermediate step in a binding.

.protobuf-serialize-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: protobuf-serialize-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: protobuf-serialize-action
properties:
schema: "message Person { required string first = 1; required string last = 2; }"
sink:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel

----

Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `protobuf-serialize-action-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the action using the following command:

[source,shell]
----
kubectl apply -f protobuf-serialize-action-binding.yaml
----
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: protobuf-deserialize-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+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3c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tzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgc3R5bGU9ImZpbGw6Y3VycmVudENvbG9yIiAvPgogIDwvZz4KPC9zdmc+Cg=="
camel.apache.org/provider: "Apache Software Foundation"
camel.apache.org/kamelet.group: "Actions"
labels:
camel.apache.org/kamelet.type: "action"
spec:
definition:
title: "Protobuf Deserialize Action"
description: "Deserialize payload to Protobuf"
type: object
required:
- schema
properties:
schema:
title: Schema
description: The Protobuf schema to use during serialization (as single-line)
type: string
example: 'message Person { required string first = 1; required string last = 2; }'
dependencies:
- "github:apache.camel-kamelets:camel-kamelets-utils:main-SNAPSHOT"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-protobuf"
flow:
from:
uri: kamelet:source
steps:
- set-property:
name: schema
constant: "{{schema}}"
- unmarshal:
protobuf:
library: Jackson
unmarshalTypeName: com.fasterxml.jackson.databind.JsonNode
schemaResolver: "#class:org.apache.camel.kamelets.utils.serialization.InflightProtobufSchemaResolver"
- remove-property:
property-name: schema
- remove-header:
header-name: "Content-Type"
Loading