Constructor
new Channel(base, optionsopt)
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| base | String | Base URL at which the streaming service resides. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| options | Object | <optional> | Options to use for the channel. Properties
 | 
- Source:
Example
// Create the channel
var channel = new Channel('http://channel-server',
  {
    auth: new ChannelAuth('http://channel-server', 'user', 'password'),
    consumerGroup: 'thegroup'
  })
// Create a new consumer on the consumer group
channel.create()Members
retryOnFail
Whether or not the channel will automatically retry a call which failed due to a temporary error.
- Source:
Methods
commit(callbackopt)
Commits the record offsets to the channel.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Callback function invoked when the commit attempt is complete.   The first parameter supplied to the callback is an  
 | 
- Source:
consume(callbackopt)
Consumes records from all the subscribed topics.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Callback function invoked when the consume attempt is complete.   The first parameter supplied to the callback is an  
 The second parameter supplied to the callback is, for a successful consume,
an array of payloads (decoded as objects) from records returned from the
server. For a failed consume, the second parameter is  | 
- Source:
Throws:
- 
        If the channel has not been subscribed to any topics. 
- Type
- PermanentError
create(callbackopt)
Creates a new consumer on the consumer group.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Callback function to invoke when the creation
  attempt has completed. The first parameter in the call to the
  results callback is an  
 | 
- Source:
delete(callbackopt)
Deletes the consumer from the consumer group.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Callback to invoke after the consumer has
  been deleted. The first parameter supplied to the callback is an  | 
- Source:
destroy(callbackopt)
Destroys the channel (releases all associated resources).
NOTE: Once the method has been invoked, no other calls should be made to the channel.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Function to invoke when the channel has been
  destroyed. The first parameter supplied to the callback is an  | 
- Source:
produce(payload, callbackopt)
Produces records to the channel.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| payload | Object | Payload containing the records to be posted to the channel. | |
| callback | function | <optional> | Function to invoke when the produce has been
  stopped. The first parameter supplied to the callback is an  | 
- Source:
reset()
Resets local consumer data stored for the channel.
- Source:
run(processCallback, optionsopt)
Repeatedly consume records from the subscribed topics. The supplied
processCallback is an array of payloads (decoded as objects) from records
returned from the server.
The processCallback should return a value of true in order for this
function to continue consuming additional records. For a return value of
false or no return value, no additional records will be consumed and this
function will return.
The Channel#stop method can also be called to halt an execution of this method.
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| processCallback | function | Callback to invoke with an array of payloads from records which have been consumed. | |||||||||||||||||||||
| options | Object | <optional> | Options to use for the channel. Properties
 | 
- Source:
Throws:
- 
        If a previous run is already in progress. 
- Type
- PermanentError
stop(callbackopt)
Stop an active execution of a Channel#run. If no run is active, the supplied callback is invoked immediately. If a run is active, the supplied callback is invoked after the run has been completed.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| callback | function | <optional> | Function to invoke when the run has been stopped. | 
- Source:
subscribe(topics, callbackopt)
Subscribes the consumer to an array of topics.
Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
| topics | String | Array.<String> | Topic or array of topics. | |
| callback | function | <optional> | Callback function invoked when the
  subscription attempt is complete. The first parameter in the call to the
  results callback is an  
 | 
- Source: