UNPKG

node-rdkafka-imhoff

Version:
3,927 lines (1,228 loc) 60.4 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Producer</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="toolkit/css/toolkit/bnet-responsive.min.css"> <link type="text/css" rel="stylesheet" href="styles/main.css"> </head> <body> <!-- HEADER --> <div class="navbar-static"> <header class="navbar header"> <div class="grid-container"> <div class="grid-25"> <a class="brand mark" href="index.html"> Class: Producer <span class="tag">3.6.11</span> </a> </div> <div class="grid-75"> <ul class="nav navbar-nav navbar-right"> <li class="dropdown"><a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#" onclick="return false;">Classes</a><ul class="dropdown-menu" role="menu"><li><a href="AdminClient.html">AdminClient</a></li><li><a href="Client.html">Client</a></li><li><a href="HighLevelProducer.html">HighLevelProducer</a></li><li><a href="KafkaConsumer.html">KafkaConsumer</a></li><li><a href="KafkaConsumerStream.html">KafkaConsumerStream</a></li><li><a href="LibrdKafkaError.html">LibrdKafkaError</a></li><li><a href="Producer.html">Producer</a></li><li><a href="ProducerStream.html">ProducerStream</a></li></ul></li><li class="dropdown"><a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#" onclick="return false;">Events</a><ul class="dropdown-menu" role="menu"><li><a href="Client.html#event:disconnected">disconnected</a></li><li><a href="Client.html#event:ready">ready</a></li><li><a href="HighLevelProducer.html#event:disconnected">disconnected</a></li><li><a href="HighLevelProducer.html#event:ready">ready</a></li><li><a href="KafkaConsumer.html#event:data">data</a></li><li><a href="KafkaConsumer.html#event:disconnected">disconnected</a></li><li><a href="KafkaConsumer.html#event:ready">ready</a></li><li><a href="Producer.html#event:disconnected">disconnected</a></li><li><a href="Producer.html#event:ready">ready</a></li></ul></li><li class="dropdown"><a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#" onclick="return false;">Tutorials</a><ul class="dropdown-menu" role="menu"><li><a href="tutorial-consumer-flow.html">consumer-flow</a></li><li><a href="tutorial-consumer-per-partition.html">consumer-per-partition</a></li><li><a href="tutorial-consumer.html">consumer</a></li><li><a href="tutorial-docker-alpine.html">docker-alpine</a></li><li><a href="tutorial-high-level-producer.html">high-level-producer</a></li><li><a href="tutorial-metadata.html">metadata</a></li><li><a href="tutorial-producer-cluster.html">producer-cluster</a></li><li><a href="tutorial-producer_.html">producer</a></li></ul></li><h3>Global</h3><ul><li><a href="global.html#createAdminClient">createAdminClient</a></li><li><a href="global.html#createSerializer">createSerializer</a></li><li><a href="global.html#RefCounter">RefCounter</a></li><li><a href="global.html#Topic">Topic</a></li><li><a href="global.html#TopicPartition">TopicPartition</a></li></ul> </ul> </div> </div> </header> </div> <!-- /HEADER --> <div class="body-content"> <div class="grid-container project-container"> <div class="grid-75 push-25"> <h1>Class: Producer</h1> <section> <header> <h2>Producer</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="Producer"> <span class="type-signature"></span>new Producer<span class="signature">(conf, topicConf)</span><span class="type-signature"></span> </h4> <div class="description"> <p>Producer class for sending messages to Kafka This is the main entry point for writing data to Kafka. You configure this like you do any other client, with a global configuration and default topic configuration. Once you instantiate this object, you need to connect to it first. This allows you to get the metadata and make sure the connection can be made before you depend on it. After that, problems with the connection will by brought down by using poll, which automatically runs when a transaction is made on the object.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">conf</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Key value pairs to configure the producer</td> </tr> <tr> <td class="name">topicConf</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Key value pairs to create a default topic configuration</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line41">producer.js, line 41</a> </li></ul> </dd> </dl> </div> <div class="clearfix"> <div class="grid-75"> <h3 class="heading-2">Extends:</h3> </div> <div class="grid-25 top-link"> <small> <a href="#top" class="inverse"> <i class="icon-chevron-up"></i> &nbsp;Back to top. </a> </small> </div> </div> <ul> <li><a href="Client.html">Client</a></li> </ul> <div class="clearfix"> <div class="grid-75"> <h3 class="heading-2">Members:</h3> </div> <div class="grid-25 top-link"> <small> <a href="#top" class="inverse"> <i class="icon-chevron-up"></i> &nbsp;Back to top. </a> </small> </div> </div> <h4 class="name" id="_disconnect"><span class="type-signature"></span>_disconnect<span class="type-signature"></span></h4> <div class="description"> <p> Save the base disconnect method here so we can overwrite it and add a flush </p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line267">producer.js, line 267</a> </li></ul> </dd> </dl> <h4 class="name" id="_metadata"><span class="type-signature"></span>_metadata<span class="type-signature"> :<a href="Client.html#~Metadata">Client~Metadata</a></span></h4> <div class="description"> <p> Metadata object. Starts out empty but will be filled with information after the initial connect. </p> </div> <h5>Type:</h5> <ul> <li> <span class="param-type"><a href="Client.html#~Metadata">Client~Metadata</a></span> </li> </ul> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#_metadata">Client#_metadata</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line101">client.js, line 101</a> </li></ul> </dd> </dl> <div class="clearfix"> <div class="grid-75"> <h3 class="heading-2">Methods:</h3> </div> <div class="grid-25 top-link"> <small> <a href="#top" class="inverse"> <i class="icon-chevron-up"></i> &nbsp;Back to top. </a> </small> </div> </div> <h4 class="name" id=".createWriteStream"> <span class="type-signature">(static) </span>createWriteStream<span class="signature">(conf, topicConf, streamOptions)</span><span class="type-signature"> &rarr; {<a href="ProducerStream.html">ProducerStream</a>}</span> </h4> <div class="description"> <p>Create a write stream interface for a producer. This stream does not run in object mode. It only takes buffers of data.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">conf</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Key value pairs to configure the producer</td> </tr> <tr> <td class="name">topicConf</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Key value pairs to create a default topic configuration</td> </tr> <tr> <td class="name">streamOptions</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Stream options</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line154">producer.js, line 154</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns the write stream for writing to Kafka. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="ProducerStream.html">ProducerStream</a></span> </dd> </dl> <h4 class="name" id="abortTransaction"> <span class="type-signature"></span>abortTransaction<span class="signature">(timeout, cb)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Aborts the ongoing transaction.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to abort, defaults to 5 seconds</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to return when operation is completed</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line348">producer.js, line 348</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="beginTransaction"> <span class="type-signature"></span>beginTransaction<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Begin a transaction. 'initTransaction' must have been called successfully (once) before this function is called.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line318">producer.js, line 318</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="commitTransaction"> <span class="type-signature"></span>commitTransaction<span class="signature">(timeout, cb)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Commit the current transaction (as started with 'beginTransaction').</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to commit before giving up, defaults to 5 seconds</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to return when operation is completed</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line331">producer.js, line 331</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="connect"> <span class="type-signature"></span>connect<span class="signature">(metadataOptions, cb)</span><span class="type-signature"> &rarr; {<a href="Client.html">Client</a>}</span> </h4> <div class="description"> <p>Connect to the broker and receive its metadata. Connects to a broker by establishing the client and fetches its metadata.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">metadataOptions</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Options to be sent to the metadata. <h6>Properties</h6> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">topic</td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Topic to fetch metadata for. Empty string is treated as empty.</td> </tr> <tr> <td class="name">allTopics</td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="description last">Fetch metadata for all topics, not just the ones we know about.</td> </tr> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">int</span> </td> <td class="description last">The timeout, in ms, to allow for fetching metadata. Defaults to 30000ms</td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type"><a href="Client.html#~connectionCallback">Client~connectionCallback</a></span> </td> <td class="description last">Callback that indicates we are done connecting.</td> </tr> </tbody> </table> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#connect">Client#connect</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line135">client.js, line 135</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Client.html">Client</a></span> </dd> </dl> <h4 class="name" id="connectedTime"> <span class="type-signature"></span>connectedTime<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span> </h4> <div class="description"> <p>Find out how long we have been connected to Kafka.</p> </div> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#connectedTime">Client#connectedTime</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line250">client.js, line 250</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Milliseconds since the connection has been established. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> <h4 class="name" id="disconnect"> <span class="type-signature"></span>disconnect<span class="signature">(timeout, cb)</span><span class="type-signature"></span> </h4> <div class="description"> <p>Disconnect the producer Flush everything on the internal librdkafka producer buffer. Then disconnect</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to flush before giving up, defaults to 5 seconds.</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">The callback to fire when</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-overrides">Overrides:</dt> <dd class="tag-overrides"><ul class="dummy"><li> <a href="Client.html#disconnect">Client#disconnect</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line277">producer.js, line 277</a> </li></ul> </dd> </dl> <h4 class="name" id="flush"> <span class="type-signature"></span>flush<span class="signature">(timeout, callback)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Flush the producer Flush everything on the internal librdkafka producer buffer. Do this before disconnects usually</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to flush before giving up.</td> </tr> <tr> <td class="name">callback</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to fire when the flush is done.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line243">producer.js, line 243</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="getClient"> <span class="type-signature"></span>getClient<span class="signature">()</span><span class="type-signature"> &rarr; {Connection}</span> </h4> <div class="description"> <p>Get the native Kafka client. You probably shouldn't use this, but if you want to execute methods directly on the c++ wrapper you can do it here.</p> </div> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#getClient">Client#getClient</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line241">client.js, line 241</a> </li></ul> </dd> <dt class="tag-see">See:</dt> <dd class="tag-see"> <ul> <li>connection.cc</li> </ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The native Kafka client. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Connection</span> </dd> </dl> <h4 class="name" id="getLastError"> <span class="type-signature"></span>getLastError<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="LibrdKafkaError.html">LibrdKafkaError</a>}</span> </h4> <div class="description"> <p>Get the last error emitted if it exists.</p> </div> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#getLastError">Client#getLastError</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line272">client.js, line 272</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Returns the LibrdKafkaError or null if one hasn't been thrown. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="LibrdKafkaError.html">LibrdKafkaError</a></span> </dd> </dl> <h4 class="name" id="getMetadata"> <span class="type-signature"></span>getMetadata<span class="signature">(metadataOptions, cb)</span><span class="type-signature"></span> </h4> <div class="description"> <p>Get client metadata. Note: using a <code>metadataOptions.topic</code> parameter has a potential side-effect. A Topic object will be created, if it did not exist yet, with default options and it will be cached by librdkafka. A subsequent call to create the topic object with specific options (e.g. <code>acks</code>) will return the previous instance and the specific options will be silently ignored. To avoid this side effect, the topic object can be created with the expected options before requesting metadata, or the metadata request can be performed for all topics (by omitting <code>metadataOptions.topic</code>).</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">metadataOptions</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">Metadata options to pass to the client. <h6>Properties</h6> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">topic</td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Topic string for which to fetch metadata</td> </tr> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Max time, in ms, to try to fetch metadata before timing out. Defaults to 3000.</td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">Client~metadataCallback</span> </td> <td class="description last">Callback to fire with the metadata.</td> </tr> </tbody> </table> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#getMetadata">Client#getMetadata</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line340">client.js, line 340</a> </li></ul> </dd> </dl> <h4 class="name" id="initTransactions"> <span class="type-signature"></span>initTransactions<span class="signature">(timeout, cb)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Init a transaction. Initialize transactions, this is only performed once per transactional producer.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to initialize before giving up, defaults to 5 seconds.</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to return when operation is completed</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line301">producer.js, line 301</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="isConnected"> <span class="type-signature"></span>isConnected<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span> </h4> <div class="description"> <p>Whether or not we are connected to Kafka.</p> </div> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#isConnected">Client#isConnected</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line262">client.js, line 262</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Whether we are connected. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="offsetsForTimes"> <span class="type-signature"></span>offsetsForTimes<span class="signature">(toppars, timeout, cb)</span><span class="type-signature"></span> </h4> <div class="description"> <p>Query offsets for times from the broker. This function makes a call to the broker to get the offsets for times specified.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">toppars</td> <td class="type"> <span class="param-type">Array.&lt;<a href="global.html#TopicPartition">TopicPartition</a>></span> </td> <td class="description last">Array of topic partitions. The offset in these should instead refer to a timestamp you want offsets for</td> </tr> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of ms to wait to recieve a response.</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type"><a href="Client.html#~offsetsForTimesCallback">Client~offsetsForTimesCallback</a></span> </td> <td class="description last">Callback to fire with the filled in offsets.</td> </tr> </tbody> </table> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#offsetsForTimes">Client#offsetsForTimes</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line423">client.js, line 423</a> </li></ul> </dd> </dl> <h4 class="name" id="poll"> <span class="type-signature"></span>poll<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Poll for events We need to run poll in order to learn about new events that have occurred. This is no longer done automatically when we produce, so we need to run it manually, or set the producer to automatically poll.</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line168">producer.js, line 168</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="produce"> <span class="type-signature"></span>produce<span class="signature">(topic, partition, message, key, timestamp, opaque, headers)</span><span class="type-signature"> &rarr; {boolean}</span> </h4> <div class="description"> <p>Produce a message to Kafka synchronously. This is the method mainly used in this class. Use it to produce a message to Kafka. When this is sent off, there is no guarantee it is delivered. If you need guaranteed delivery, change your *acks* settings, or use delivery reports.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">topic</td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The topic name to produce to.</td> </tr> <tr> <td class="name">partition</td> <td class="type"> <span class="param-type">number</span> | <span class="param-type">null</span> </td> <td class="description last">The partition number to produce to.</td> </tr> <tr> <td class="name">message</td> <td class="type"> <span class="param-type">Buffer</span> | <span class="param-type">null</span> </td> <td class="description last">The message to produce.</td> </tr> <tr> <td class="name">key</td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The key associated with the message.</td> </tr> <tr> <td class="name">timestamp</td> <td class="type"> <span class="param-type">number</span> | <span class="param-type">null</span> </td> <td class="description last">Timestamp to send with the message.</td> </tr> <tr> <td class="name">opaque</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">An object you want passed along with this message, if provided.</td> </tr> <tr> <td class="name">headers</td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last">A list of custom key value pairs that provide message metadata.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line123">producer.js, line 123</a> </li></ul> </dd> <dt class="tag-see">See:</dt> <dd class="tag-see"> <ul> <li><a href="Producer.html#produce">Producer#produce</a></li> </ul> </dd> </dl> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Throws:</h4> </div> </div> <dl> <dt> <div class="param-desc"> - Throws a librdkafka error if it failed. </div> </dt> <dd></dd> <dt> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="LibrdKafkaError.html">LibrdKafkaError</a></span> </dd> </dl> </dt> <dd></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns an error if it failed, or true if not </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="queryWatermarkOffsets"> <span class="type-signature"></span>queryWatermarkOffsets<span class="signature">(topic, partition, timeout, cb)</span><span class="type-signature"></span> </h4> <div class="description"> <p>Query offsets from the broker. This function makes a call to the broker to get the current low (oldest/beginning) and high (newest/end) offsets for a topic partition.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">topic</td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">Topic to recieve offsets from.</td> </tr> <tr> <td class="name">partition</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Partition of the provided topic to recieve offsets from</td> </tr> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of ms to wait to recieve a response.</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type"><a href="Client.html#~watermarkOffsetsCallback">Client~watermarkOffsetsCallback</a></span> </td> <td class="description last">Callback to fire with the offsets.</td> </tr> </tbody> </table> <dl class="details"> <dt class="inherited-from">Inherited From:</dt> <dd class="inherited-from"><ul class="dummy"><li> <a href="Client.html#queryWatermarkOffsets">Client#queryWatermarkOffsets</a> </li></ul></dd> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="client.js.html#line377">client.js, line 377</a> </li></ul> </dd> </dl> <h4 class="name" id="sendOffsetsToTransaction"> <span class="type-signature"></span>sendOffsetsToTransaction<span class="signature">(offsets, consumer, timeout, cb)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Send the current offsets of the consumer to the ongoing transaction.</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name">offsets</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Offsets to send as part of the next commit</td> </tr> <tr> <td class="name">consumer</td> <td class="type"> <span class="param-type">Consumer</span> </td> <td class="description last">An instance of the consumer</td> </tr> <tr> <td class="name">timeout</td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">Number of milliseconds to try to send offsets, defaults to 5 seconds</td> </tr> <tr> <td class="name">cb</td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Callback to return when operation is completed</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"> <ul class="pager"><li> <a href="producer.js.html#line367">producer.js, line 367</a> </li></ul> </dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - returns itself. </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Producer.html">Producer</a></span> </dd> </dl> <h4 class="name" id="setPollInterval"> <span class="type-signature"></span>setPollInterval<span class="signature">(interval)</span><span class="type-signature"> &rarr; {<a href="Producer.html">Producer</a>}</span> </h4> <div class="description"> <p>Set automatic polling for events. We need to run poll in order to learn about new events that have occurred. If you would like this done on an interval with disconnects and reconnections managed, you can do it here</p> </div> <div class="clearfix"> <div class="grid-75"> <h4 class="heading-3">Parameters:</h4> </div> </div> <table class="params table table-striped"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Desc