0.0.9 • Published 5 years ago

@specialblend/kafka-pipe v0.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

kafka-pipe

A functional/fluent utility for kafka, built on top of kafka-node.

Install

npm install @specialblend/kafka-pipe

Classes

Constants

PipeConsumer

Callable kafka Consumer with pipe and error helper methods

Kind: global class

pipeConsumer.pipe(handler) ⇒ PipeConsumer

Pipe incoming messages to provided handler

Kind: instance method of PipeConsumer
Returns: PipeConsumer - self

ParamTypeDescription
handlerfunctionmessage handler function

pipeConsumer.error(handler) ⇒ PipeConsumer

Alias for this.on('error')

Kind: instance method of PipeConsumer
Returns: PipeConsumer - self

ParamTypeDescription
handlerfunctionerror handler function

pipeConsumer.__call__(handler) ⇒ PipeConsumer

Make instance callable alias of this.pipe

Kind: instance method of PipeConsumer
Returns: PipeConsumer - self

ParamTypeDescription
handlerfunctionmessage handler function

PipeProducer

Callable kafka Producer when instance is called directly, acts like PipeProducer.send

Kind: global class

new PipeProducer(client, options)

Create

ParamTypeDescription
clientClientkafka client
optionsObjectopyions

pipeProducer.send(payload) ⇒ Promise.<*>

Send a payload

Kind: instance method of PipeProducer
Returns: Promise.<*> - result

ParamTypeDescription
payloadArray.<String>payload

pipeProducer.__call__(payload) ⇒ Promise.<*>

Make instance callable alias of this.send

Kind: instance method of PipeProducer
Returns: Promise.<*> - result

ParamTypeDescription
payloadArray.<String>payload

PipeSender

Callable kafka PipeProducer which allows presetting a destination topic and options

Kind: global class

new PipeSender(client, topic, payloadOptions, producerOptions)

Curry topic and payload options

ParamTypeDescription
clientClientkafka client
topicStringkafka topic name
payloadOptionsObjectoptions to include with outgoing payloads
producerOptionsObjectproducer options

pipeSender.send(messages) ⇒ Promise.<*>

Send messages to preset topic, with preset options

Kind: instance method of PipeSender
Returns: Promise.<*> - returned Promise

ParamTypeDescription
messagesArray.<String>an array of messages to send

pipeSender.__call__(payload) ⇒ Promise.<*>

Make instance callable alias of this.send

Kind: instance method of PipeSender
Returns: Promise.<*> - result

ParamTypeDescription
payloadArray.<String>payload

PipeTransformer

Consumer/producer mixin that pipes messages from sourceTopic into transformer function, and sends result to destinationTopic, or deadLetterTopic on error

Kind: global class

new PipeTransformer(transformer, client, sourceTopic, destinationTopic, deadLetterTopic)

create a PipeTransformer

ParamTypeDescription
transformerfunctionthe transformer function
clientClientkafka Client
sourceTopicStringname of topic to read from
destinationTopicStringname of topic to send to
deadLetterTopicStringname of topic to send failed payloads

Client

Kafka Client

Kind: global class

new Client(kafkaHost, options)

Create a kafka Client

ParamTypeDescription
kafkaHostStringkafka host
optionsObjectoptions

createConsumer ⇒ PipeConsumer

Curried factory of PipeConsumer

Kind: global constant

createProducer ⇒ PipeProducer

Curried factory of PipeProducer

Kind: global constant

createSender ⇒ PipeSender

Curried factory of PipeProducer

Kind: global constant

createTransformer ⇒ PipeTransformer

Curried factory of PipeTransformer

Kind: global constant

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago