2.1.0 • Published 8 years ago

kafka-rest-publisher-client v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

kafka-rest-publisher-client

A thin wrapper above Kafka REST

Usage

const KafkaRestPublisherClient = require( 'kafka-rest-publisher-client' );

const host = 'http://localhost:8082';
const topic = 'toSpace';

// all message fields are optional
const message = {
    key: 'someKey',
    value: 'someValue',
    partition: 0
} );

const client = new KafkaRestPublisher( { host } );

client.publish( topic, message ) // single message or array
    .then( console.log );
/*
    offsets: [
        {
            partition: 0,
            offset: 0,
            error_code: null,
            error: null
        }
    ],
    key_schema_id: null,
    value_schema_id: null
*/

client.checkConnection()
    .then( console.log );
/* true */

Nocker

const kafkaRestNocker = require( 'kafka-rest-publisher-client/nocker' );
const nock = require( 'nock' );

const host = 'http://localhost:8082';

const nocker = kafkaRestNocker( host, nock );

nocker.mockHost(); // Ensures that host is mocked

nocker.mockPublish( host );
nocker.mockPublish( host, {
    code: 500,
    body: {
        message: 'Some error'
    }
} );

nocker.mockCheckConnection();
nocker.mockCheckConnection( {
    code: 500,
    body: {
        message: 'Some error'
    }
} );
2.1.0

8 years ago

2.0.0

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago