-
Notifications
You must be signed in to change notification settings - Fork 348
feat(connectors): add SurrealDB sink connector #3453
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
Open
countradooku
wants to merge
22
commits into
apache:master
Choose a base branch
from
countradooku:feat/surrealdb-sink-connector
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,053
−2
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
48c3a9d
feat(connectors): add SurrealDB sink connector
countradooku 1a2b917
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku 5373ee4
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku 30075ea
style(connectors): align SurrealDB license headers
countradooku e89b508
chore(connectors): remove unused SurrealDB dev dependency
countradooku 78afe35
fix(connectors): address surrealdb sink review feedback
a4ed78e
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku 2ef6199
fix(server): install default jwt crypto provider
countradooku 6befc06
fix(tests): install jwt crypto provider for a2a tokens
countradooku 94eb76b
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku f5059a6
ci(cpp): harden cargo registry fetches
countradooku 87262c5
fix(connectors): address surrealdb sink review
countradooku 14231f5
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku 93922ae
fix(connectors): initialize surrealdb http namespace
countradooku dd32945
fix(connectors): preserve surrealdb checksum range
countradooku e0426f8
fix(connectors): address surrealdb review nits
countradooku 8f822f5
fix(connectors): tighten surrealdb sink validation
countradooku 757afd9
fix(connectors): preserve surrealdb valid records
countradooku 3a17c84
fix(tests): align surrealdb metadata assertions
countradooku 4b6492e
Merge branch 'master' into feat/surrealdb-sink-connector
hubcio 00343e6
fix(connectors): address surrealdb follow-up review
countradooku e9cd7d4
Merge branch 'master' into feat/surrealdb-sink-connector
countradooku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| [package] | ||
| name = "iggy_connector_surrealdb_sink" | ||
| version = "0.4.1-edge.1" | ||
| description = "Iggy SurrealDB sink connector for writing stream messages into SurrealDB" | ||
| edition = "2024" | ||
| license = "Apache-2.0" | ||
| keywords = ["iggy", "messaging", "streaming", "surrealdb", "sink"] | ||
| categories = ["command-line-utilities", "database", "network-programming"] | ||
| homepage = "https://iggy.apache.org" | ||
| documentation = "https://iggy.apache.org/docs" | ||
| repository = "https://github.com/apache/iggy" | ||
| readme = "../../README.md" | ||
| publish = false | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib", "lib"] | ||
|
|
||
| [dependencies] | ||
| async-trait = { workspace = true } | ||
| base64 = { workspace = true } | ||
| bytes = { workspace = true } | ||
| iggy_common = { workspace = true } | ||
| iggy_connector_sdk = { workspace = true } | ||
| reqwest = { workspace = true } | ||
| secrecy = { workspace = true } | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } | ||
| tokio = { workspace = true } | ||
| tracing = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| simd-json = { workspace = true } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # SurrealDB Sink Connector | ||
|
|
||
| Writes Apache Iggy stream messages into SurrealDB over the HTTP API. | ||
|
|
||
| The sink writes one SurrealQL bulk `INSERT IGNORE` per connector batch. Each | ||
| record uses a deterministic SurrealDB record id derived from stream, topic, | ||
| partition, offset and Iggy message id, so replayed batches are idempotent and | ||
| existing records are left untouched. | ||
|
countradooku marked this conversation as resolved.
|
||
|
|
||
| Persistent sink failures are at-most-once from the runtime's perspective: | ||
| messages may already be committed in Iggy before this connector exhausts its | ||
| write attempts, so failed writes are logged but not redelivered. | ||
|
|
||
| ## Configuration | ||
|
|
||
| ```toml | ||
| type = "sink" | ||
| key = "surrealdb" | ||
| enabled = true | ||
| version = 0 | ||
| name = "SurrealDB sink" | ||
| path = "target/release/libiggy_connector_surrealdb_sink" | ||
| plugin_config_format = "toml" | ||
|
|
||
| [[streams]] | ||
| stream = "example_stream" | ||
| topics = ["example_topic"] | ||
| schema = "json" | ||
| batch_length = 1000 | ||
| poll_interval = "5ms" | ||
| consumer_group = "surrealdb_sink_connector" | ||
|
|
||
| [plugin_config] | ||
| endpoint = "127.0.0.1:8000" | ||
| namespace = "iggy" | ||
| database = "connectors" | ||
| table = "iggy_messages" | ||
| username = "root" | ||
| password = "root" | ||
| auth_scope = "root" | ||
| use_tls = false | ||
| auto_define_table = true | ||
| define_indexes = true | ||
| batch_size = 1000 | ||
| payload_format = "auto" | ||
| include_metadata = true | ||
| include_headers = true | ||
| include_checksum = true | ||
| include_origin_timestamp = true | ||
| query_timeout = "30s" | ||
| max_retries = 3 | ||
| retry_delay = "100ms" | ||
| max_retry_delay = "5s" | ||
| verbose_logging = false | ||
| ``` | ||
|
|
||
| ### Plugin Fields | ||
|
|
||
| | Field | Default | Description | | ||
| | --- | --- | --- | | ||
| | `endpoint` | required | SurrealDB HTTP host and port without scheme, for example `127.0.0.1:8000`. Full `http://` or `https://` URLs are also accepted. | | ||
| | `namespace` | required | SurrealDB namespace selected during `open()`. | | ||
| | `database` | required | SurrealDB database selected during `open()`. | | ||
| | `table` | required | Target table. Must be a safe SurrealQL identifier. | | ||
| | `username` / `password` | none | Optional credentials. | | ||
| | `auth_scope` | `root` | `root`, `namespace`, `database`, or `none`. | | ||
| | `use_tls` | `false` | Uses `https://` when true and `endpoint` has no scheme, `http://` otherwise. | | ||
| | `auto_define_table` | `false` | Runs `DEFINE TABLE IF NOT EXISTS <table> SCHEMALESS`. | | ||
| | `define_indexes` | `false` | Defines an offset index on stream/topic/partition/offset. Requires `auto_define_table`. | | ||
| | `batch_size` | `1000` | Maximum number of records per SurrealDB request. | | ||
| | `payload_format` | `auto` | `auto`, `json`, `text`, `base64`, or `binary` (`binary` is an alias for `base64`). | | ||
| | `include_metadata` | `true` | Stores stream/topic/partition/offset/timestamps/schema fields. | | ||
| | `include_headers` | `true` | Stores Iggy headers as a deterministic object. Raw headers are base64 encoded. | | ||
| | `include_checksum` | `true` | Stores `iggy_checksum`. | | ||
| | `include_origin_timestamp` | `true` | Stores `iggy_origin_timestamp`. | | ||
| | `query_timeout` | `30s` | SurrealDB HTTP request timeout. | | ||
| | `max_retries` | `3` | Total attempts for transient write failures. Values below `1` are raised to `1`. | | ||
| | `retry_delay` | `100ms` | Base retry delay. | | ||
| | `max_retry_delay` | `5s` | Capped exponential retry delay. | | ||
| | `verbose_logging` | `false` | Emits per-batch success logs at `info`. | | ||
|
|
||
| ## Stored Shape | ||
|
|
||
| With metadata enabled, records contain: | ||
|
|
||
| - `id`: deterministic SurrealDB record id key | ||
| - `iggy_message_id`: original Iggy message id as a string | ||
| - `iggy_stream`, `iggy_topic`, `iggy_partition_id`, `iggy_offset` | ||
| - `iggy_timestamp`, `iggy_origin_timestamp`, `iggy_checksum`, `iggy_schema` | ||
| - `iggy_headers` | ||
| - `payload` | ||
| - `payload_encoding` | ||
|
|
||
| `payload_format = "auto"` stores decoded JSON payloads as queryable SurrealDB | ||
| values, text payloads as strings, and binary payloads as base64 strings. | ||
|
|
||
| The `messages_processed` counter reports valid records submitted to SurrealDB. | ||
| With `INSERT IGNORE`, duplicates can be ignored by SurrealDB while still being | ||
| counted as submitted. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| type = "sink" | ||
| key = "surrealdb" | ||
| enabled = true | ||
| version = 0 | ||
| name = "SurrealDB sink" | ||
| path = "target/release/libiggy_connector_surrealdb_sink" | ||
| plugin_config_format = "toml" | ||
| verbose = false | ||
| benchmark = false | ||
|
|
||
| [[streams]] | ||
| stream = "example_stream" | ||
| topics = ["example_topic"] | ||
| schema = "json" | ||
| batch_length = 1000 | ||
| poll_interval = "5ms" | ||
| consumer_group = "surrealdb_sink_connector" | ||
|
|
||
| [plugin_config] | ||
| endpoint = "127.0.0.1:8000" | ||
| namespace = "iggy" | ||
| database = "connectors" | ||
| table = "iggy_messages" | ||
| username = "root" | ||
| password = "root" | ||
| auth_scope = "root" | ||
| use_tls = false | ||
| auto_define_table = true | ||
| define_indexes = true | ||
| batch_size = 1000 | ||
| payload_format = "auto" | ||
| include_metadata = true | ||
| include_headers = true | ||
| include_checksum = true | ||
| include_origin_timestamp = true | ||
| query_timeout = "30s" | ||
| # Total write attempts for transient failures. Minimum is 1. A value of 0 is raised to 1. | ||
| max_retries = 3 | ||
| retry_delay = "100ms" | ||
| max_retry_delay = "5s" | ||
| verbose_logging = false |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.