KafkaOptionsBuilder
此内容尚不支持你的语言。
Defined in: src/io/broker/KafkaOptions.ts:57
Extends
Section titled “Extends”BrokerOptionsBuilder<KafkaOptionsType>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new KafkaOptionsBuilder():
KafkaOptionsBuilder
Returns
Section titled “Returns”KafkaOptionsBuilder
Inherited from
Section titled “Inherited from”BrokerOptionsBuilder<KafkaOptionsType>.constructor
Methods
Section titled “Methods”build()
Section titled “build()”build():
Partial<T>
Defined in: src/util/OptionsBuilder.ts:51
Snapshot the set fields as an independent Partial<T> (own props only).
Returns
Section titled “Returns”Partial<T>
Inherited from
Section titled “Inherited from”BrokerOptionsBuilder.build
withBrokers()
Section titled “withBrokers()”withBrokers(
brokers):this
Defined in: src/io/broker/KafkaOptions.ts:64
Bootstrap servers ('kafka-1:9092,kafka-2:9092' or array).
Parameters
Section titled “Parameters”brokers
Section titled “brokers”string | readonly string[]
Returns
Section titled “Returns”this
withCircuitBreaker()
Section titled “withCircuitBreaker()”withCircuitBreaker(
failureThreshold,resetMs):this
Defined in: src/io/broker/BrokerOptions.ts:125
Circuit breaker around connect attempts.
Parameters
Section titled “Parameters”failureThreshold
Section titled “failureThreshold”number
resetMs
Section titled “resetMs”number
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BrokerOptionsBuilder.withCircuitBreaker
withClientId()
Section titled “withClientId()”withClientId(
clientId):this
Defined in: src/io/broker/KafkaOptions.ts:69
Stable client id reported to the broker.
Parameters
Section titled “Parameters”clientId
Section titled “clientId”string
Returns
Section titled “Returns”this
withConsumer()
Section titled “withConsumer()”withConsumer(
consumer):this
Defined in: src/io/broker/KafkaOptions.ts:89
Consumer options. groupId is required to start a consumer.
Parameters
Section titled “Parameters”consumer
Section titled “consumer”commitMode?
Section titled “commitMode?”KafkaCommitMode
Offset-commit policy. Default 'auto' — kafkajs auto-commits
after the handler returns (at-least-once). See
KafkaCommitMode for the 'manual' (exactly-once-with-
processing) shape.
commitTimeoutMs?
Section titled “commitTimeoutMs?”number
Max time in ms the manual-commit pump waits for an external
commit / nack before giving up on a message and letting
kafkajs reject it (which triggers a rebalance and re-delivery).
Only used when commitMode === 'manual'. Default 30s.
fromBeginning?
Section titled “fromBeginning?”boolean
groupId?
Section titled “groupId?”string
Returns
Section titled “Returns”this
withOutboundBuffer()
Section titled “withOutboundBuffer()”withOutboundBuffer(
limit):this
Defined in: src/io/broker/BrokerOptions.ts:130
Outbound buffer size (messages held while disconnected). Default 1000; 0 = fail-fast.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BrokerOptionsBuilder.withOutboundBuffer
withProducer()
Section titled “withProducer()”withProducer(
producer):this
Defined in: src/io/broker/KafkaOptions.ts:84
Producer options (idempotence / auto-topic-creation).
Parameters
Section titled “Parameters”producer
Section titled “producer”allowAutoTopicCreation?
Section titled “allowAutoTopicCreation?”boolean
idempotent?
Section titled “idempotent?”boolean
Returns
Section titled “Returns”this
withReconnect()
Section titled “withReconnect()”withReconnect(
policy):this
Defined in: src/io/broker/BrokerOptions.ts:120
Reconnect policy (or false to disable auto-reconnect).
Parameters
Section titled “Parameters”policy
Section titled “policy”false | { factor?: number; initialDelayMs?: number; maxAttempts?: number; maxDelayMs?: number; } | undefined
false
Type Literal
Section titled “Type Literal”{ factor?: number; initialDelayMs?: number; maxAttempts?: number; maxDelayMs?: number; }
factor?
Section titled “factor?”number
initialDelayMs?
Section titled “initialDelayMs?”number
maxAttempts?
Section titled “maxAttempts?”number
Cap on retry attempts. Default: Infinity (retry forever).
maxDelayMs?
Section titled “maxDelayMs?”number
undefined
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”BrokerOptionsBuilder.withReconnect
withSasl()
Section titled “withSasl()”withSasl(
sasl):this
Defined in: src/io/broker/KafkaOptions.ts:74
SASL credentials.
Parameters
Section titled “Parameters”mechanism
Section titled “mechanism”"plain" | "scram-sha-256" | "scram-sha-512"
password
Section titled “password”string
username
Section titled “username”string
Returns
Section titled “Returns”this
withSsl()
Section titled “withSsl()”withSsl(
on?):this
Defined in: src/io/broker/KafkaOptions.ts:79
Enable TLS. Default false.
Parameters
Section titled “Parameters”boolean = true
Returns
Section titled “Returns”this
withTarget()
Section titled “withTarget()”withTarget(
target):this
Defined in: src/io/broker/KafkaOptions.ts:94
Subscriber that receives every consumed record.
Parameters
Section titled “Parameters”target
Section titled “target”Returns
Section titled “Returns”this
withTopics()
Section titled “withTopics()”withTopics(
topics):this
Defined in: src/io/broker/KafkaOptions.ts:99
Topics the consumer subscribes to at connect time.
Parameters
Section titled “Parameters”topics
Section titled “topics”readonly string[]
Returns
Section titled “Returns”this
create()
Section titled “create()”
staticcreate():KafkaOptionsBuilder
Defined in: src/io/broker/KafkaOptions.ts:59
Start a fresh builder. Equivalent to new KafkaOptionsBuilder().
Returns
Section titled “Returns”KafkaOptionsBuilder
