[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74CN8KEF5GH3JFSTHH4EJ7T":3,"skill-same:01M74CN8KEF5GH3JFSTHH4EJ7T":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M74CN8KEF5GH3JFSTHH4EJ7T","connector-sink",null,"Author a new Apache Iggy connector sink plugin under sinks\u002F. Sinks consume messages from Apache Iggy streams and push them to an external system (DB, search engine, HTTP endpoint, object store). Load when creating, modifying, or reviewing a sink crate. Use for sink plugin authoring. NOT for runtime internals (see connector-runtime).","apache\u002Figgy-connectors","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M74CMTGQZXBYXVEKC91YP22N",5,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-sink\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: connector-sink\ndescription: Author a new Apache Iggy connector sink plugin under sinks\u002F. Sinks consume messages from Apache Iggy streams and push them to an external system (DB, search engine, HTTP endpoint, object store). Load when creating, modifying, or reviewing a sink crate. Use for sink plugin authoring. NOT for runtime internals (see connector-runtime).\n---\n\n# Writing an Apache Iggy Connector Sink\n\nA **sink** is a Rust `cdylib` that implements `iggy_connector_sdk::Sink`\nand exposes FFI symbols via the `sink_connector!` macro. The runtime\nloads it as `.so`\u002F`.dylib`\u002F`.dll`, polls Apache Iggy on its behalf,\nruns the transform chain, decodes via the configured `Schema`, and\nhands the sink batches of `ConsumedMessage`. The sink is responsible\nfor getting them to the external system reliably and efficiently.\n\n> **Universal connector rules** (SecretString, benchmark, verbose flag, drop accounting, filter contract, exemplar patterns) live in\n> [connectors-overview](..\u002Fconnectors-overview\u002FSKILL.md). This skill\n> covers only what's sink-specific.\n\n## Contents\n\n- [STOP and ask the user before](#stop-and-ask-the-user-before)\n- [Quick reference](#quick-reference)\n- [Hard rules](#hard-rules)\n- [Common pitfalls](#common-pitfalls)\n- [Tests](#tests)\n- [Before declaring done](#before-declaring-done)\n\n## STOP and ask the user before\n\n- Changing the SDK trait surface (`Sink::open` \u002F `consume` \u002F `close`) - that's an SDK change, not a plugin one.\n- Touching default `batch_size`, retry caps, or backoff defaults baked into existing in-tree sinks.\n- Promoting an `Err` variant to retryable when it previously was not - retrying bad data trips circuit breakers.\n- Adding a new sink that introduces a backend the runtime doesn't yet integration-test for.\n\n## Quick reference\n\n- Skeleton: [TEMPLATE.md](TEMPLATE.md) (load on demand when authoring).\n- Exemplars: `stdout_sink` (minimal), `postgres_sink` (DB + transient detection), `http_sink` (validation, batch modes, retry middleware), `mongodb_sink` (atomic counters), `elasticsearch_sink` \u002F `iceberg_sink` (backend-specific idioms).\n\n## Hard rules\n\n### Lifecycle\n\n- `Sink::consume` takes **`&self`** - never `&mut self`. Mutable state goes behind `tokio::sync::Mutex` \u002F `AtomicU64`. Prefer atomics for hot counters - `mongodb_sink` uses `messages_processed: AtomicU64` + `insertion_errors: AtomicU64` and avoids a state lock on the hot path entirely.\n- `Sink::open` builds the client AND tests connectivity. Fail fast with `Error::InitError`.\n- `Sink::close` flushes + drops resources. Take ownership via `client: Option\u003CClient>` + `.take()`. sqlx pools have `.close().await`. reqwest\u002Fmongodb\u002Felasticsearch clients just drop. Log final stats either way.\n\n### Config\n\n- Every runtime-tunable field is `Option\u003CT>` with a default applied in `new()`. Forward-compat: adding a field doesn't break existing TOML.\n- Durations: `Option\u003CString>`, parsed via `humantime::Duration` in `new()`. Two equivalent in-tree idioms - inline `HumanDuration::from_str(&raw).map(|d| *d).unwrap_or_else(..)` (`random_source`, `postgres_source`) or a local `parse_duration` helper (`http_sink`, `sdk\u002Fsrc\u002Fretry.rs`). Fall back to a default on parse failure with `warn!` - never panic. We do **not** use `humantime_serde`.\n- **Conflict resolution**: if two config fields can be in invalid relative ordering, fix it in `new()` + `warn!` - don't error. `http_sink` swaps `retry_delay` and `max_retry_delay` when reversed to avoid an `ExponentialBackoff` panic downstream.\n- Validation order: structural in `new()`, connectivity in `open()`, **never in `consume()`**.\n\n### Payloads (efficiency-critical)\n\n- Dispatch on the `Payload` variant. Handle `Json`, `Raw`, `Text` and `Proto` at minimum. `Proto` holds text that is a JSON document when `proto_convert` had no descriptor or could not encode, and arbitrary text otherwise: call `Payload::json_document()` first and fall back to the text handling when it returns `None`. Unsupported -> `Error::InvalidPayloadType` or fall back to base64 (`elasticsearch_sink`).\n- For `Payload::Json`, call `try_to_bytes(&self)` - single-pass serialization without cloning the `OwnedValue` tree (`sdk\u002Fsrc\u002Flib.rs::Payload::try_to_bytes`). Never `payload.clone().try_into_vec()`.\n- To take a payload out of `ConsumedMessage` without cloning: `std::mem::replace(&mut message.payload, Payload::Raw(vec![]))`. Standard pattern across `http_sink::send_individual` \u002F `send_ndjson` \u002F `send_json_array`.\n- Pre-allocate per-batch buffers with `Vec::with_capacity(messages.len())` (or `* factor` for serialized bodies). Used across `postgres_sink`, `mongodb_sink`, `quickwit_sink`, `elasticsearch_sink`, `http_sink`.\n\n### Headers\n\n- `message.headers: Option\u003CBTreeMap\u003CHeaderKey, HeaderValue>>`. Check `.is_empty()` before iterating - runtime treats empty as `None`.\n- Name every header with `iggy_connector_sdk::HeaderName`, never with `to_string_value()`, which collides `1` with `\"1\"` and renders raw keys as Debug text. `HeaderName` gives each key one stable, unique name.\n- For a new sink that writes JSON, write the whole map with `iggy_connector_sdk::JsonHeaders` (`{data, data_encoding}` per value). For another value shape, take the text from `headers::HeaderData` and the base64 check from `headers::JsonHeaderValue::data_encoding`. See `meilisearch_sink::headers_document`.\n- Released sinks keep their documented value shape: binary values as `v.as_raw()` + base64 (`http_sink::EncodedHeader`), text as `v.to_string_value()`.\n- Test header naming with the shared cases in `testing\u002Fsrc\u002Fheaders.rs` (`header_cases`, `header_case_map`). A sink that cannot write a case skips it by label, as RabbitMQ does with `LONG_RAW_KEY_CASE`.\n- `BTreeMap` for deterministic ordering. Don't collect into `HashMap`.\n\n### Errors\n\n| Scenario                                   | SDK variant                                                                 | Retry?                                                                   |\n| ------------------------------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Init \u002F connectivity failure                | `Error::InitError`                                                          | n\u002Fa (fails open)                                                         |\n| Bad config value                           | `Error::InvalidConfigValue(field)`                                          | n\u002Fa                                                                      |\n| Single-message validation failure          | `Error::InvalidRecordValue(reason)`                                         | no - skip + log; under at-least-once, fail the call (stops the sink)     |\n| Transient backend (5xx, conn reset, ...)   | `Error::HttpRequestFailed` \u002F `Error::Connection` \u002F `Error::CannotStoreData` | yes                                                                      |\n| Permanent 4xx, schema mismatch, constraint | `Error::PermanentHttpError` \u002F `Error::SchemaMismatch`                       | **no** - retrying trips circuit breakers                                 |\n| I\u002FO failure mid-write (parquet\u002Ficeberg)    | `Error::WriteFailure`                                                       | caller decides                                                           |\n| Catalog commit failure (Iceberg)           | `Error::CatalogCommitError`                                                 | not in place (txn consumed); under at-least-once, the runtime redelivers |\n\n`Error::is_permanent()` (`sdk\u002Fsrc\u002Flib.rs`) is the class the runtime acts on for an at-least-once sink: a permanent error stops the delivery, a transient one hands the messages over again. `CatalogCommitError` is transient there, because the redelivered messages rebuild the transaction, and a commit that did land shows up as a duplicate, which at-least-once allows.\n\n### Retry\n\n- SDK helpers cover the simple case: `iggy_connector_sdk::retry::check_connectivity_with_retry(...)` for `open()`, `HttpRetryMiddleware` for default 429\u002F5xx\u002Fnetwork policy on reqwest clients.\n- Custom strategies: `reqwest-middleware` + `reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy`. `http_sink` defines its own `HttpSinkRetryStrategy` (honors `success_status_codes`, per-status decisions).\n- Non-HTTP clients: write `is_transient_error(&e)` mapping driver-specific codes. `postgres_sink::is_transient_error` maps SQLSTATEs `40001`, `40P01`, `57P01-03`, `08000\u002F03\u002F06`.\n- Retry loop: new connectors use `iggy_connector_sdk::retry::retry_async(policy, context, should_retry, op)` for anything that fails as `Err`. It owns attempt counting, backoff and the per-retry log, and returns `RetryFailure { error, attempts, exhausted }`; the caller logs the terminal failure.\n- Backoff only, for a loop that computes its own delay (it retries on an `Ok` response, carries a deadline, or reconnects between attempts): `retry_backoff(base, retry, max)`, where `retry` is 1-based. `exponential_backoff` is the 0-based primitive underneath, and it applies no jitter; call it directly only when the delay must be exact, as `sdk\u002Fsrc\u002Fsource.rs::nack_retry_delay` needs for its tests.\n- Cap retries at 3 total attempts.\n\n### Idempotency\n\nRuntime retries on any `Err` - same batch can be redelivered. In-tree guarantees:\n\n- **Postgres** (`postgres_sink::build_batch_insert_query`): PK on `id`, but plain `INSERT` (no `ON CONFLICT`). Duplicate retry triggers `23505`, `is_transient_error` does NOT mark it transient -> error propagates. Adding `ON CONFLICT (id) DO NOTHING` is a known improvement.\n- **MongoDB**: composite `_id` from `stream:topic:partition:message_id`, via `insert_many(docs).ordered(false)`. Per-document duplicate-key errors don't abort the batch - effective idempotency under retry.\n- **Elasticsearch** (`bulk_index_documents`): bulk action specifies only `_index`, no `_id` -> ES auto-generates ids -> NOT idempotent. Extensions should add `\"_id\"`.\n- **HTTP**: endpoint-dependent. Document in the plugin README.\n- **Iceberg**: transactional commit per table. `router\u002Fcommit.rs` tags each snapshot with `iggy.commit-id`, and a commit retry first checks whether the catalog already holds it. At least once, `router\u002Fredelivery.rs` records the first offset and the last message of each source partition in the snapshot summary. A redelivered batch that carries the last message of an append on the current snapshot history skips the start of the batch that such appends cover without a gap.\n\nWhen writing a new sink, prefer dedup-on-write using the message `id` field. Mongo's upsert-style is the cleanest reference.\n\n### Batching\n\n- Default `batch_size: 100`. Tune per-backend.\n- Chunk via `messages.chunks(self.batch_size)`. Do not buffer across `consume()` - runtime already batches at the consumer-poll boundary.\n- For HTTP backends support multiple batch modes when applicable (individual \u002F ndjson \u002F json_array \u002F raw). See `http_sink::BatchMode`.\n\n### Logging\n\n```rust\ninfo!(\"Opened \u003Cconnector> connector ID: {}, endpoint: \u003Credacted>\", self.id);\ndebug!(\"Processing batch of {} messages, offset: {}\", batch.len(), offset);\nwarn!(\"Retry {attempt}\u002F{max} for \u003Cconnector> ID: {}, reason: {error}\", self.id);\nerror!(\"Failed to \u003Cop> for \u003Cconnector> ID: {}, error: {error}\", self.id);\ninfo!(\"Closed \u003Cconnector> connector ID: {}, processed: {}\", self.id, count);\n```\n\nUse literal API field names as labels (`offset=`, `current_offset=`).\n\n## Common pitfalls\n\n1. Missing `[lib] crate-type = [\"cdylib\", \"lib\"]` - runtime can't dlopen a regular rlib.\n2. Cloning the whole `Payload::Json` to serialize - use `try_to_bytes(&self)`.\n3. Holding `Mutex` across `.await` when the locked region does I\u002FO.\n4. `&mut self` on `consume` - won't compile. you need interior mutability.\n5. Returning the first error and dropping subsequent batches - track `last_err`, process all, return.\n6. Forgetting to map `PermanentHttpError` - retries hammer the backend with bad data.\n7. Mutating config in `consume()` - config is a snapshot from `new()`. Reload requires runtime restart.\n8. Logging the connection string. Redact at construction: `http_sink::sanitize_url_for_log` populates `HttpSink.log_url`.\n\n## Tests\n\nUnit tests at EOF of `src\u002Flib.rs`. See [connector-testing](..\u002Fconnector-testing\u002FSKILL.md) for BDD naming + `test_config()` helper.\n\nReal-infra integration tests live in the sink's own test target `sinks\u002F\u003Cname>_sink\u002Ftests\u002F\u003Cbackend>\u002F` (entry `main.rs`) using `#[iggy_harness]` + a backend fixture that spins up Docker via `testcontainers-modules`. Plugins integrating with external services must have an integration test. Reference: `sinks\u002Fpostgres_sink\u002Ftests\u002Fpostgres\u002Fpostgres_sink.rs` + `fixtures\u002F`.\n\n## Before declaring done\n\n```bash\ncargo fmt --all\ncargo sort --no-format --grouped --workspace\ncargo clippy -p iggy_connector_\u003Cname>_sink --all-targets -- -D warnings\ncargo nextest run -p iggy_connector_\u003Cname>_sink --lib\n\n# Integration tests (Docker, .\u002Fscripts\u002Fbuild-test-server.sh once per core pin).\n# The harness launches target\u002Fdebug\u002Figgy-connectors, which loads the plugin from target\u002Fdebug\u002F:\ncargo build -p iggy-connectors -p iggy_connector_\u003Cname>_sink\ncargo nextest run -p iggy_connector_\u003Cname>_sink --test \u003Cbackend> \u003Ctest_name>\n```\n\nA new sink also needs its directory in `members` of the root `Cargo.toml` (new dependencies go to `[workspace.dependencies]`), a row for its test target in `.config\u002Frail.toml`, a row in the sinks table of the root `README.md`, and a sample TOML under `runtime\u002Fexample_config\u002Fconnectors\u002F`.\n\n---\n\nDiscussion \u002F help: see [AGENTS.md](..\u002F..\u002F..\u002FAGENTS.md#discussion-and-support).\n","# Writing an Apache Iggy Connector Sink\n\nA **sink** is a Rust `cdylib` that implements `iggy_connector_sdk::Sink`\nand exposes FFI symbols via the `sink_connector!` macro. The runtime\nloads it as `.so`\u002F`.dylib`\u002F`.dll`, polls Apache Iggy on its behalf,\nruns the transform chain, decodes via the configured `Schema`, and\nhands the sink batches of `ConsumedMessage`. The sink is responsible\nfor getting them to the external system reliably and efficiently.\n\n> **Universal connector rules** (SecretString, benchmark, verbose flag, drop accounting, filter contract, exemplar patterns) live in\n> [connectors-overview](..\u002Fconnectors-overview\u002FSKILL.md). This skill\n> covers only what's sink-specific.\n\n## Contents\n\n- [STOP and ask the user before](#stop-and-ask-the-user-before)\n- [Quick reference](#quick-reference)\n- [Hard rules](#hard-rules)\n- [Common pitfalls](#common-pitfalls)\n- [Tests](#tests)\n- [Before declaring done](#before-declaring-done)\n\n## STOP and ask the user before\n\n- Changing the SDK trait surface (`Sink::open` \u002F `consume` \u002F `close`) - that's an SDK change, not a plugin one.\n- Touching default `batch_size`, retry caps, or backoff defaults baked into existing in-tree sinks.\n- Promoting an `Err` variant to retryable when it previously was not - retrying bad data trips circuit breakers.\n- Adding a new sink that introduces a backend the runtime doesn't yet integration-test for.\n\n## Quick reference\n\n- Skeleton: [TEMPLATE.md](TEMPLATE.md) (load on demand when authoring).\n- Exemplars: `stdout_sink` (minimal), `postgres_sink` (DB + transient detection), `http_sink` (validation, batch modes, retry middleware), `mongodb_sink` (atomic counters), `elasticsearch_sink` \u002F `iceberg_sink` (backend-specific idioms).\n\n## Hard rules\n\n### Lifecycle\n\n- `Sink::consume` takes **`&self`** - never `&mut self`. Mutable state goes behind `tokio::sync::Mutex` \u002F `AtomicU64`. Prefer atomics for hot counters - `mongodb_sink` uses `messages_processed: AtomicU64` + `insertion_errors: AtomicU64` and avoids a state lock on the hot path entirely.\n- `Sink::open` builds the client AND tests connectivity. Fail fast with `Error::InitError`.\n- `Sink::close` flushes + drops resources. Take ownership via `client: Option\u003CClient>` + `.take()`. sqlx pools have `.close().await`. reqwest\u002Fmongodb\u002Felasticsearch clients just drop. Log final stats either way.\n\n### Config\n\n- Every runtime-tunable field is `Option\u003CT>` with a default applied in `new()`. Forward-compat: adding a field doesn't break existing TOML.\n- Durations: `Option\u003CString>`, parsed via `humantime::Duration` in `new()`. Two equivalent in-tree idioms - inline `HumanDuration::from_str(&raw).map(|d| *d).unwrap_or_else(..)` (`random_source`, `postgres_source`) or a local `parse_duration` helper (`http_sink`, `sdk\u002Fsrc\u002Fretry.rs`). Fall back to a default on parse failure with `warn!` - never panic. We do **not** use `humantime_serde`.\n- **Conflict resolution**: if two config fields can be in invalid relative ordering, fix it in `new()` + `warn!` - don't error. `http_sink` swaps `retry_delay` and `max_retry_delay` when reversed to avoid an `ExponentialBackoff` panic downstream.\n- Validation order: structural in `new()`, connectivity in `open()`, **never in `consume()`**.\n\n### Payloads (efficiency-critical)\n\n- Dispatch on the `Payload` variant. Handle `Json`, `Raw`, `Text` and `Proto` at minimum. `Proto` holds text that is a JSON document when `proto_convert` had no descriptor or could not encode, and arbitrary text otherwise: call `Payload::json_document()` first and fall back to the text handling when it returns `None`. Unsupported -> `Error::InvalidPayloadType` or fall back to base64 (`elasticsearch_sink`).\n- For `Payload::Json`, call `try_to_bytes(&self)` - single-pass serialization without cloning the `OwnedValue` tree (`sdk\u002Fsrc\u002Flib.rs::Payload::try_to_bytes`). Never `payload.clone().try_into_vec()`.\n- To take a payload out of `ConsumedMessage` without cloning: `std::mem::replace(&mut message.payload, Payload::Raw(vec![]))`. Standard pattern across `http_sink::send_individual` \u002F `send_ndjson` \u002F `send_json_array`.\n- Pre-allocate per-batch buffers with `Vec::with_capacity(messages.len())` (or `* factor` for serialized bodies). Used across `postgres_sink`, `mongodb_sink`, `quickwit_sink`, `elasticsearch_sink`, `http_sink`.\n\n### Headers\n\n- `message.headers: Option\u003CBTreeMap\u003CHeaderKey, HeaderValue>>`. Check `.is_empty()` before iterating - runtime treats empty as `None`.\n- Name every header with `iggy_connector_sdk::HeaderName`, never with `to_string_value()`, which collides `1` with `\"1\"` and renders raw keys as Debug text. `HeaderName` gives each key one stable, unique name.\n- For a new sink that writes JSON, write the whole map with `iggy_connector_sdk::JsonHeaders` (`{data, data_encoding}` per value). For another value shape, take the text from `headers::HeaderData` and the base64 check from `headers::JsonHeaderValue::data_encoding`. See `meilisearch_sink::headers_document`.\n- Released sinks keep their documented value shape: binary values as `v.as_raw()` + base64 (`http_sink::EncodedHeader`), text as `v.to_string_value()`.\n- Test header naming with the shared cases in `testing\u002Fsrc\u002Fheaders.rs` (`header_cases`, `header_case_map`). A sink that cannot write a case skips it by label, as RabbitMQ does with `LONG_RAW_KEY_CASE`.\n- `BTreeMap` for deterministic ordering. Don't collect into `HashMap`.\n\n### Errors\n\n| Scenario                                   | SDK variant                                                                 | Retry?                                                                   |\n| ------------------------------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------ |\n| Init \u002F connectivity failure                | `Error::InitError`                                                          | n\u002Fa (fails open)                                                         |\n| Bad config value                           | `Error::InvalidConfigValue(field)`                                          | n\u002Fa                                                                      |\n| Single-message validation failure          | `Error::InvalidRecordValue(reason)`                                         | no - skip + log; under at-least-once, fail the call (stops the sink)     |\n| Transient backend (5xx, conn reset, ...)   | `Error::HttpRequestFailed` \u002F `Error::Connection` \u002F `Error::CannotStoreData` | yes                                                                      |\n| Permanent 4xx, schema mismatch, constraint | `Error::PermanentHttpError` \u002F `Error::SchemaMismatch`                       | **no** - retrying trips circuit breakers                                 |\n| I\u002FO failure mid-write (parquet\u002Ficeberg)    | `Error::WriteFailure`                                                       | caller decides                                                           |\n| Catalog commit failure (Iceberg)           | `Error::CatalogCommitError`                                                 | not in place (txn consumed); under at-least-once, the runtime redelivers |\n\n`Error::is_permanent()` (`sdk\u002Fsrc\u002Flib.rs`) is the class the runtime acts on for an at-least-once sink: a permanent error stops the delivery, a transient one hands the messages over again. `CatalogCommitError` is transient there, because the redelivered messages rebuild the transaction, and a commit that did land shows up as a duplicate, which at-least-once allows.\n\n### Retry\n\n- SDK helpers cover the simple case: `iggy_connector_sdk::retry::check_connectivity_with_retry(...)` for `open()`, `HttpRetryMiddleware` for default 429\u002F5xx\u002Fnetwork policy on reqwest clients.\n- Custom strategies: `reqwest-middleware` + `reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy`. `http_sink` defines its own `HttpSinkRetryStrategy` (honors `success_status_codes`, per-status decisions).\n- Non-HTTP clients: write `is_transient_error(&e)` mapping driver-specific codes. `postgres_sink::is_transient_error` maps SQLSTATEs `40001`, `40P01`, `57P01-03`, `08000\u002F03\u002F06`.\n- Retry loop: new connectors use `iggy_connector_sdk::retry::retry_async(policy, context, should_retry, op)` for anything that fails as `Err`. It owns attempt counting, backoff and the per-retry log, and returns `RetryFailure { error, attempts, exhausted }`; the caller logs the terminal failure.\n- Backoff only, for a loop that computes its own delay (it retries on an `Ok` response, carries a deadline, or reconnects between attempts): `retry_backoff(base, retry, max)`, where `retry` is 1-based. `exponential_backoff` is the 0-based primitive underneath, and it applies no jitter; call it directly only when the delay must be exact, as `sdk\u002Fsrc\u002Fsource.rs::nack_retry_delay` needs for its tests.\n- Cap retries at 3 total attempts.\n\n### Idempotency\n\nRuntime retries on any `Err` - same batch can be redelivered. In-tree guarantees:\n\n- **Postgres** (`postgres_sink::build_batch_insert_query`): PK on `id`, but plain `INSERT` (no `ON CONFLICT`). Duplicate retry triggers `23505`, `is_transient_error` does NOT mark it transient -> error propagates. Adding `ON CONFLICT (id) DO NOTHING` is a known improvement.\n- **MongoDB**: composite `_id` from `stream:topic:partition:message_id`, via `insert_many(docs).ordered(false)`. Per-document duplicate-key errors don't abort the batch - effective idempotency under retry.\n- **Elasticsearch** (`bulk_index_documents`): bulk action specifies only `_index`, no `_id` -> ES auto-generates ids -> NOT idempotent. Extensions should add `\"_id\"`.\n- **HTTP**: endpoint-dependent. Document in the plugin README.\n- **Iceberg**: transactional commit per table. `router\u002Fcommit.rs` tags each snapshot with `iggy.commit-id`, and a commit retry first checks whether the catalog already holds it. At least once, `router\u002Fredelivery.rs` records the first offset and the last message of each source partition in the snapshot summary. A redelivered batch that carries the last message of an append on the current snapshot history skips the start of the batch that such appends cover without a gap.\n\nWhen writing a new sink, prefer dedup-on-write using the message `id` field. Mongo's upsert-style is the cleanest reference.\n\n### Batching\n\n- Default `batch_size: 100`. Tune per-backend.\n- Chunk via `messages.chunks(self.batch_size)`. Do not buffer across `consume()` - runtime already batches at the consumer-poll boundary.\n- For HTTP backends support multiple batch modes when applicable (individual \u002F ndjson \u002F json_array \u002F raw). See `http_sink::BatchMode`.\n\n### Logging\n\n```rust\ninfo!(\"Opened \u003Cconnector> connector ID: {}, endpoint: \u003Credacted>\", self.id);\ndebug!(\"Processing batch of {} messages, offset: {}\", batch.len(), offset);\nwarn!(\"Retry {attempt}\u002F{max} for \u003Cconnector> ID: {}, reason: {error}\", self.id);\nerror!(\"Failed to \u003Cop> for \u003Cconnector> ID: {}, error: {error}\", self.id);\ninfo!(\"Closed \u003Cconnector> connector ID: {}, processed: {}\", self.id, count);\n```\n\nUse literal API field names as labels (`offset=`, `current_offset=`).\n\n## Common pitfalls\n\n1. Missing `[lib] crate-type = [\"cdylib\", \"lib\"]` - runtime can't dlopen a regular rlib.\n2. Cloning the whole `Payload::Json` to serialize - use `try_to_bytes(&self)`.\n3. Holding `Mutex` across `.await` when the locked region does I\u002FO.\n4. `&mut self` on `consume` - won't compile. you need interior mutability.\n5. Returning the first error and dropping subsequent batches - track `last_err`, process all, return.\n6. Forgetting to map `PermanentHttpError` - retries hammer the backend with bad data.\n7. Mutating config in `consume()` - config is a snapshot from `new()`. Reload requires runtime restart.\n8. Logging the connection string. Redact at construction: `http_sink::sanitize_url_for_log` populates `HttpSink.log_url`.\n\n## Tests\n\nUnit tests at EOF of `src\u002Flib.rs`. See [connector-testing](..\u002Fconnector-testing\u002FSKILL.md) for BDD naming + `test_config()` helper.\n\nReal-infra integration tests live in the sink's own test target `sinks\u002F\u003Cname>_sink\u002Ftests\u002F\u003Cbackend>\u002F` (entry `main.rs`) using `#[iggy_harness]` + a backend fixture that spins up Docker via `testcontainers-modules`. Plugins integrating with external services must have an integration test. Reference: `sinks\u002Fpostgres_sink\u002Ftests\u002Fpostgres\u002Fpostgres_sink.rs` + `fixtures\u002F`.\n\n## Before declaring done\n\n```bash\ncargo fmt --all\ncargo sort --no-format --grouped --workspace\ncargo clippy -p iggy_connector_\u003Cname>_sink --all-targets -- -D warnings\ncargo nextest run -p iggy_connector_\u003Cname>_sink --lib\n\n# Integration tests (Docker, .\u002Fscripts\u002Fbuild-test-server.sh once per core pin).\n# The harness launches target\u002Fdebug\u002Figgy-connectors, which loads the plugin from target\u002Fdebug\u002F:\ncargo build -p iggy-connectors -p iggy_connector_\u003Cname>_sink\ncargo nextest run -p iggy_connector_\u003Cname>_sink --test \u003Cbackend> \u003Ctest_name>\n```\n\nA new sink also needs its directory in `members` of the root `Cargo.toml` (new dependencies go to `[workspace.dependencies]`), a row for its test target in `.config\u002Frail.toml`, a row in the sinks table of the root `README.md`, and a sample TOML under `runtime\u002Fexample_config\u002Fconnectors\u002F`.\n\n---\n\nDiscussion \u002F help: see [AGENTS.md](..\u002F..\u002F..\u002FAGENTS.md#discussion-and-support).\n",{"name":5,"description":7},"master","bd42e8e56dfc1f6bfb7a34b0577407271521e809",".claude\u002Fskills\u002Fconnector-sink",9,"https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors","https:\u002F\u002Figgy.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-14 16:40:07",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add apache\u002Figgy-connectors --skill connector-sink",{"tool":39,"command":40},"bunx","bunx skills add apache\u002Figgy-connectors --skill connector-sink",{"tool":42,"command":43},"pnpm","pnpm dlx skills add apache\u002Figgy-connectors --skill connector-sink","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-sink\u002FSKILL.md",true,[47],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"TEMPLATE.md","REFERENCE","参考文档",6028,"https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-sink\u002FTEMPLATE.md",[54,61,68,75,82,89],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M74CNZYB8S4XAQ9G19VTP7S0","team-review","Four expert review of a PR, branch, or ref range.\nUse only when the user explicitly requests team-review.","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fteam-review\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M74CMY09QP0D2TK15BN1P1XK","connector-review","Adversarial review of a connectors PR, branch, or ref range, with clean-room validation of every finding. Experts\nwork alone and use the focused connector skills as their source of subsystem rules.\nUse only when the user explicitly requests connector-review.","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-review\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M74CNWVGHJ6GFK6CMCX6H0YE","connectors-overview","Entry point and index for the Apache Iggy Connectors repository. Load this first when working anywhere in it - runtime, SDK, sinks, sources, transforms, or their tests. Routes to the focused per-area skills.","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnectors-overview\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M74CNKY8NRVGY59SK1V2ZSY5","connector-transform","Add a new transform under `sdk\u002Fsrc\u002Ftransforms\u002F`. Transforms mutate, filter, or convert messages between source\u002Fencode and decode\u002Fsink. Use when adding field-level transforms (add\u002Fdelete\u002Fupdate\u002Ffilter), format conversions, envelope unwrapping, or similar config-driven message manipulations for Apache Iggy connectors. Use for transform authoring. NOT for runtime internals or sink\u002Fsource loops.","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-transform\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M74CNF6BYDHCVW5YX8Y5D6KW","connector-testing","Write tests for Apache Iggy connectors - sinks, sources, transforms, SDK, runtime. Covers BDD unit-test naming, the canonical source state round-trip tests, and the real-infra integration test targets under `\u003Cpackage>\u002Ftests\u002F\u003Csuite>\u002F` with `testcontainers-modules` + `#[iggy_harness]`. Load when writing or reviewing tests anywhere in this repository (`src\u002F` unit tests, `tests\u002F` targets, `testing\u002F`). Use for connector test authoring. NOT for runtime internals or non-connector test patterns.","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-testing\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M74CNBQE9HSA111QAN094YC4","connector-source","Author a new Apache Iggy connector source plugin under sources\u002F. Sources poll an external system (DB, API, queue) and produce messages into Apache Iggy streams. Load when creating, modifying, or reviewing a source crate. Use for source plugin authoring. NOT for runtime internals (see connector-runtime).","https:\u002F\u002Fgithub.com\u002Fapache\u002Figgy-connectors\u002Fblob\u002Fmaster\u002F.claude\u002Fskills\u002Fconnector-source\u002FSKILL.md",[],[]]