{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/source/pulsar",
  "title" : "Pulsar Source Configuration",
  "description" : "The `pulsar` source consumes data from Apache Pulsar topics. It allows configuration of consumer properties,\nsuch as topic names, service URL, subscription name, subscription type, and more.\nThis source is suitable for integrating real-time data from Pulsar into your streaming pipeline.\n",
  "type" : "object",
  "properties" : {
    "pulsar" : {
      "type" : "object",
      "properties" : {
        "serviceUrl" : {
          "type" : "string",
          "description" : "The service URL for connecting to the Pulsar cluster. For example: pulsar://localhost:6650 or pulsar+ssl://pulsar.example.com:6651"
        },
        "topicNames" : {
          "description" : "Set of topic names to consume from. Topics should follow Pulsar naming convention: persistent://tenant/namespace/topic",
          "anyOf" : [ {
            "type" : "string"
          }, {
            "type" : "array",
            "description" : "Set of topic names to consume from. Topics should follow Pulsar naming convention: persistent://tenant/namespace/topic",
            "uniqueItems" : true,
            "items" : {
              "type" : "string"
            }
          } ]
        },
        "subscriptionName" : {
          "type" : "string",
          "description" : "The subscription name for this consumer. Multiple consumers with the same subscription name will share messages according to the subscription type."
        },
        "subscriptionType" : {
          "type" : "string",
          "description" : "The subscription type determines how messages are distributed:\n- EXCLUSIVE: Only one consumer can be active at a time\n- SHARED: Messages are distributed across multiple consumers\n- FAILOVER: One consumer receives messages until it fails, then another takes over\n- KEY_SHARED: Messages with the same key go to the same consumer\n",
          "default" : "SHARED",
          "enum" : [ "exclusive", "shared", "failover", "key_shared", "EXCLUSIVE", "SHARED", "FAILOVER", "KEY_SHARED" ]
        },
        "consumerName" : {
          "type" : "string",
          "description" : "Optional consumer name for identification purposes."
        },
        "receiveTimeout" : {
          "type" : "string",
          "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
          "description" : "The maximum time to wait for a message.",
          "default" : "1s"
        },
        "properties" : {
          "type" : "object",
          "description" : "Adds or overrides specific Pulsar client properties, allowing customization for advanced configurations.",
          "additionalProperties" : {
            "type" : "string"
          }
        },
        "ssl" : {
          "type" : "object",
          "description" : "SSL configuration.",
          "properties" : {
            "trustStoreFile" : {
              "type" : "string",
              "description" : "Truststore file or trusted CA certificate; supported formats include JKS, PKCS#12, or PEM."
            },
            "trustStorePassword" : {
              "type" : "string",
              "description" : "Truststore password."
            },
            "keyStoreFile" : {
              "type" : "string",
              "description" : "Keystore file; supported formats include JKS, PKCS#12, or PEM"
            },
            "keyStorePassword" : {
              "type" : "string",
              "description" : "Keystore password."
            },
            "keyPassword" : {
              "type" : "string",
              "description" : "Private key password. Optional — if not set, the key store password will be used."
            },
            "insecure" : {
              "type" : "boolean",
              "description" : "If set to true, disables SSL certificate and hostname validation.\nIntended for debugging purposes only. Doesn't work with mTLS.\n"
            },
            "hostnameVerifier" : {
              "type" : "string",
              "description" : "Custom hostname verifier for SSL connections.\nIf not specified and 'insecure' is true, hostname verification will be disabled.\n"
            }
          },
          "additionalProperties" : false
        },
        "authToken" : {
          "type" : "string",
          "description" : "Authentication token for Pulsar authentication."
        },
        "exceptionHandler" : {
          "type" : "string",
          "description" : "Custom exception handler enabling interception of all errors related to this source."
        },
        "subscriptionInitialPosition" : {
          "type" : "string",
          "description" : "The initial position for the subscription when first created.\nEARLIEST starts from the beginning of the topic, LATEST starts from new messages only.",
          "default" : "EARLIEST",
          "enum" : [ "earliest", "latest", "EARLIEST", "LATEST" ]
        },
        "deadLetterTopic" : {
          "type" : "string",
          "description" : "Dead letter topic name for messages that fail processing.\nMessages that exceed max redelivery count will be sent to this topic."
        },
        "maxRedeliveryCount" : {
          "type" : "integer",
          "description" : "Maximum number of times a message will be redelivered before being sent to the dead letter topic.",
          "default" : "0",
          "minimum" : -2147483648,
          "maximum" : 2147483647
        },
        "negativeAckRedeliveryDelay" : {
          "type" : "string",
          "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
          "description" : "Delay before redelivering negatively acknowledged messages.\nThis gives the system time to recover from transient failures.",
          "default" : "1m"
        },
        "ackTimeout" : {
          "type" : "string",
          "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
          "description" : "Timeout for acknowledging messages.\nIf a message is not acknowledged within this time, it will be redelivered.",
          "default" : "0s"
        },
        "batchReceiveMaxMessages" : {
          "type" : "integer",
          "description" : "Maximum number of messages to receive in a single batch.\nBatch receiving improves throughput by processing multiple messages at once.",
          "default" : "100",
          "minimum" : -2147483648,
          "maximum" : 2147483647
        },
        "batchReceiveTimeout" : {
          "type" : "string",
          "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
          "description" : "Maximum time to wait for a full batch before processing partial batch.\nThis prevents indefinite waiting when message rate is low.",
          "default" : "100ms"
        }
      },
      "required" : [ "serviceUrl", "topicNames", "subscriptionName", "subscriptionType" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "pulsar" ],
  "additionalProperties" : false
}
