{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "https://www.krakend.io/schema/v3.0/messaging/kafka/producer.json",
  "title": "Kafka Producer Details",
  "description": "Enterprise only. Defines details about how to write messages to a Kafka cluster",
  "type": "object",
  "properties": {
    "max_message_bytes": {
      "title": "Max Message Bytes",
      "description": "Maximum permitted size of a message. Should be set equal to or smaller than the broker's `message.max.bytes`.",
      "type": "number",
      "minimum": 0
    },
    "required_acks": {
      "title": "Required Acks",
      "description": "Level of acknowledgement reliability needed from the broker. Equivalent to the `request.required.acks` setting of the JVM producer. Can be a positibe number (as a string), or one of hte following values: `no_response` (no required acks), `wait_for_local` (waits for only the local commit to succeed before responding), `wait_for_all` (waits for all in-sync replicas to commit before responding).",
      "default": "wait_for_local",
      "type": "string"
    },
    "required_acks_timeout": {
      "title": "Required Acks Timeout",
      "description": "Maximum duration the broker will wait the receipt of the number of `required_acks`. This is only relevant when `required_acks` is set to WaitForAll or a number > 1. Only supports millisecond resolution, nanoseconds will be truncated. Equivalent to the JVM producer's `request.timeout.ms` setting.",
      "default": "10s",
      "$ref": "../../timeunits.json#/$defs/timeunit",
      "type": "string"
    },
    "compression_codec": {
      "title": "Compression Codec",
      "description": "Type of compression to use on messages (defaults to no compression). Similar to `compression.codec` setting of the JVM producer.",
      "default": "none",
      "enum": [ "none", "gzip", "snappy", "lz4", "zstd" ]
    },
    "compression_level": {
      "title": "Compression Level",
      "description": "Level of compression to use on messages. The meaning depends on the actual compression type used and defaults to default compression level for the codec.",
      "type": "string"
    },
    "partitioner": {
      "title": "Partitioner",
      "description": "Select behaviour for choosing the partition to send messages (similar to the `partitioner.class` setting for the JVM producer). The options are:\n- `sarama`: **DEPRECATED** uses a Partitioner which behaves as follows: If the message's key is nil then a random partition is chosen. Otherwise the `FNV-1a` hash of the encoded bytes of the message key is used, modulus the number of partitions. This ensures that messages with the same key always end up on the same partition.\n- `standard` is like `sarama` except that it handles absolute values in the same way as the reference Java implementation. `sarama` was supposed to do that but it had a mistake and now there are people depending on both behaviours. This will all go away on the next major version bump.\n- `random` uses a Partitioner which chooses a random partition each time.\n- `roundrobin` uses a Partitioner which walks through the available partitions one at a time.",
      "default": "standard",
      "enum": [ "sarama", "standard", "random", "roundrobin" ]
    },
    "idempotent": {
      "title": "Idempotent",
      "description": "If enabled, the producer will ensure that exactly one copy of each message is written",
      "default": false,
      "type": "boolean"
    },
    "retry_max": {
      "title": "Retry Max",
      "description": "The total number of times to retry sending a message. Similar to the `message.send.max.retries` setting of the JVM producer.",
      "default": 3,
      "type": "number",
      "minimum": 0
    },
    "retry_backoff": {
      "title": "Retry Backoff",
      "description": "How long to wait for the cluster to settle between retries (similar to the `retry.backoff.ms` setting of the JVM producer.",
      "default": "100ms",
      "$ref": "../../timeunits.json#/$defs/timeunit",
      "type": "string"
    }
  },
  "patternProperties": {
    "^[@$_#]": true
  },
  "additionalProperties": false
}
