From 863e8cba8129325092fdba6b5d402f9dc220b42d Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 8 Jul 2024 11:43:36 +0200 Subject: [PATCH] bridge: Add kafka to example configs, config tests --- bridge/svix-bridge.example.receivers.yaml | 15 ++++++++ bridge/svix-bridge.example.senders.yaml | 27 ++++++++++++++ bridge/svix-bridge/src/config/tests.rs | 43 +++++++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/bridge/svix-bridge.example.receivers.yaml b/bridge/svix-bridge.example.receivers.yaml index 31122e3fa..6c912e9e6 100644 --- a/bridge/svix-bridge.example.receivers.yaml +++ b/bridge/svix-bridge.example.receivers.yaml @@ -109,3 +109,18 @@ receivers: # - `AWS_SECRET_ACCESS_KEY` type: "sqs" queue_dsn: "https://aws.example.com/my-queue" + + - name: "forward-to-kafka-example" + input: + type: "webhook" + path_id: "kafka" + verification: + type: "none" + output: + kafka_bootstrap_brokers: "localhost:9094" + kafka_topic: "foobar" + # Other valid values: "plaintext", "ssl" + kafka_security_protocol: "sasl_ssl" + # Only for SASL + kafka_sasl_username: "user" + kafka_sasl_password: "pass" diff --git a/bridge/svix-bridge.example.senders.yaml b/bridge/svix-bridge.example.senders.yaml index be97fb232..710c0a0ae 100644 --- a/bridge/svix-bridge.example.senders.yaml +++ b/bridge/svix-bridge.example.senders.yaml @@ -135,3 +135,30 @@ senders: type: "svix" # Required (the Svix token to use when creating messages with this consumer) token: "XYZ" + + # Kafka Consumer + - name: "kafka-example" + input: + kafka_bootstrap_brokers: "localhost:9094" + kafka_group_id: "kafka_example_consumer_group" + kafka_topic: "foobar" + # Other valid values: "plaintext", "ssl" + kafka_security_protocol: "sasl_ssl" + # Only for SASL + kafka_sasl_username: "user" + kafka_sasl_password: "pass" + # Optional - when unset, messages from the queue will be sent to Svix as-is. + transformation: | + function handler(input) { + return { + appId: input.key, + message: { + eventType: input.event_type, + payload: input.data + } + }; + } + output: + type: "svix" + # Required (the Svix token to use when creating messages with this consumer) + token: "XYZ" diff --git a/bridge/svix-bridge/src/config/tests.rs b/bridge/svix-bridge/src/config/tests.rs index c294d0614..dc412223e 100644 --- a/bridge/svix-bridge/src/config/tests.rs +++ b/bridge/svix-bridge/src/config/tests.rs @@ -146,6 +146,33 @@ senders: # Required (the Svix token to use when creating messages with this consumer) token: "XYZ" + # Kafka Consumer + - name: "kafka-example" + input: + kafka_bootstrap_brokers: "localhost:9094" + kafka_group_id: "kafka_example_consumer_group" + kafka_topic: "foobar" + # Other valid values: "plaintext", "ssl" + kafka_security_protocol: "sasl_ssl" + # Only for SASL + kafka_sasl_username: "user" + kafka_sasl_password: "pass" + # Optional - when unset, messages from the queue will be sent to Svix as-is. + transformation: | + function handler(input) { + return { + appId: input.key, + message: { + eventType: input.event_type, + payload: input.data + } + }; + } + output: + type: "svix" + # Required (the Svix token to use when creating messages with this consumer) + token: "XYZ" + # Receivers are HTTP endpoints that can have webhooks sent to them. # When a webhook is POST'ed to a matching URL, it is (optionally) verified, @@ -237,6 +264,22 @@ receivers: # - `AWS_SECRET_ACCESS_KEY` type: "sqs" queue_dsn: "https://example.aws.com/my-queue" + + - name: "forward-to-kafka-example" + input: + type: "webhook" + path_id: "kafka" + verification: + type: "none" + output: + kafka_bootstrap_brokers: "localhost:9094" + kafka_topic: "foobar" + # Other valid values: "plaintext", "ssl" + kafka_security_protocol: "sasl_ssl" + # Only for SASL + kafka_sasl_username: "user" + kafka_sasl_password: "pass" + "#; #[test]