Connectors / Streaming & queues

Apache Kafka

source

Apache Kafka consumer with idle/max-messages termination

Install

cargo install faucet-cli --features source-kafka
faucet init --source kafka
# Cargo.toml — use it as a library
cargo add faucet-source-kafka

Starter config

source:
  type: kafka
  config:
    brokers: ""    # REQUIRED — Comma-separated bootstrap server list, e.g.
    topics: []    # REQUIRED — One or more topics to subscribe to.
    group_id: ""    # REQUIRED — Consumer group ID; required by librdkafka and used for partition assignment.
    # auth: { type: none }    # one of: none, sasl_plain, sasl_scram, ssl, sasl_ssl, tls
      # --- Alternative variants — replace the block above with one of these ---
      # type: sasl_plain
      # config:
        # username: ""    # REQUIRED
        # password: ""    # REQUIRED
      #
      # type: sasl_scram
      # config:
        # mechanism: null    # REQUIRED
        # username: ""    # REQUIRED
        # password: ""    # REQUIRED
      #
      # type: ssl
      # config:
        # ca_path: ""    # REQUIRED
        # cert_path: ""    # REQUIRED
        # key_path: ""    # REQUIRED
        # key_password: ""
      #
      # type: sasl_ssl
      # config:
        # sasl: null    # REQUIRED
        # ssl: null    # REQUIRED
      #
      # type: tls
      # config:
        # ca_path: ""
    # value_format: { type: json }    # one of: json, raw_string, bytes, confluent_avro, confluent_protobuf, confluent_json_schema
      # --- Alternative variants — replace the block above with one of these ---
      # type: raw_string
      #
      # type: bytes
      #
      # type: confluent_avro
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      # bytes_encoding: null
      #
      # type: confluent_protobuf
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      #
      # type: confluent_json_schema
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      # validate: false
    # key_format: { type: json }    # one of: json, raw_string, bytes, confluent_avro, confluent_protobuf, confluent_json_schema
      # --- Alternative variants — replace the block above with one of these ---
      # type: raw_string
      #
      # type: bytes
      #
      # type: confluent_avro
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      # bytes_encoding: null
      #
      # type: confluent_protobuf
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      #
      # type: confluent_json_schema
      # schema_registry:
        # url: ""    # REQUIRED
        # auth: null
        # cache_capacity: 1024
        # request_timeout: 10
      # validate: false
    # auto_offset_reset: ""    # one of: earliest, latest
    # max_messages: 0    # Stop after this many messages have been consumed.
    # idle_timeout: 0    # Stop after this many seconds of no new messages.
    # poll_timeout: 1    # Single-poll timeout (advisory).
    # session_timeout: 30    # Kafka `session.timeout.ms`.
    # on_decode_error: null    # What the source does when a single message fails to decode.
    # extra_client_config: {}    # Raw librdkafka client properties to pass through.
    # batch_size: 1000    # Messages per emitted `StreamPage`.

Capabilities

Replay Deterministic replay
Exactly-once replay Yes
Incremental Yes
Dataset discovery No
Reports lag Yes
Compression No

Config fields

FieldTypeDefaultDescription
brokers
required
string — Comma-separated bootstrap server list, e.g. "broker1:9092,broker2:9092".
topics
required
array — One or more topics to subscribe to.
group_id
required
string — Consumer group ID; required by librdkafka and used for partition assignment.
auth object type: none How to authenticate to the brokers. Defaults to none (PLAINTEXT) — override for SASL/TLS clusters.
value_format object type: json How to decode the message **value**. Defaults to json; the schema-registry formats need the kafka-schema-registry feature.
key_format object — Format for the message key. None (the default) decodes key bytes as UTF-8 (or null if there is no key on the message).
auto_offset_reset string latest Where to start when the group has no committed offset: latest (default) consumes only new messages, earliest replays the retained log. Ignored once a bookmark or committed offset exists.
max_messages integer — Stop after this many messages have been consumed. At least one of max_messages and idle_timeout must be set.
idle_timeout integer — Stop after this many seconds of no new messages.
poll_timeout integer 1 Single-poll timeout (advisory). Default 1 second.
session_timeout integer 30 Kafka session.timeout.ms. Default 30 seconds.
on_decode_error object fail What a message that fails to decode does: fail the run (default), or skip the message and continue.
extra_client_config object — Raw librdkafka client properties to pass through. Use with care — these can override anything set by auth or the typed fields above.
batch_size integer 1000 Messages per emitted StreamPage. Messages drained from the consumer are accumulated into an in-memory buffer and yielded whenever the buffer reaches this size or the idle window flushes a partially-filled buffer. Defaults to DEFAULT_BATCH_SIZE.
Get started

Your first pipeline runs in five minutes.

Install the CLI, scaffold a config, and move real data — nothing external to stand up.

curl -LsSf https://github.com/faucet-hq/faucet-stream/releases/latest/download/faucet-cli-installer.sh | sh
brew install faucet-hq/faucet-stream/faucet-cli