Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 8514a33

Browse files
author
Daniel Olivares
committed
fix(API): Changed the createConsumer and createProducer methjods
createConsumer and createProducer methods would generate a promise when none is needed. Also cleaned up documentation due to connect() not returning itself. create clients methods are no longer promises
1 parent 08a7af8 commit 8514a33

7 files changed

Lines changed: 17 additions & 13 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ import iris from '@parkhub/iris';
122122
}
123123
});
124124

125+
await consumer.connect();
126+
125127
const handler = data => console.log(data);
126128
consumer.subscribe(['MY_TOPIC'], handler);
127129

@@ -153,7 +155,9 @@ import iris from '@parkhub/iris';
153155
const producer = await iris.createProducer({
154156
'client.id': 'kafka',
155157
'dr_cb': true
156-
}).connect();
158+
});
159+
160+
await producer.connect();
157161

158162
producer.produce('TestTopic', null, 'message');
159163

__tests__/both.integration.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Running combined producer consume test', () => {
3636

3737
kafka = await iris({ registryUrl, brokerList, schemaCfgs }).initialize();
3838

39-
const consumer = await kafka.createConsumer({
39+
const consumer = kafka.createConsumer({
4040
groupId: 'BothIntegrationTest',
4141
event_cb: true
4242
});
@@ -54,7 +54,7 @@ describe('Running combined producer consume test', () => {
5454
consumer.subscribe([testTopic], handler);
5555

5656
setTimeout(async () => {
57-
const producer = await kafka.createProducer();
57+
const producer = kafka.createProducer();
5858
await producer.connect();
5959

6060
producer.produce(testTopic, null, message);

__tests__/fixtures/scripts/waitForServicesToBeAvailable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function waitForServicesToBeAvailable(tries = 0) {
1515
try {
1616
log(`Making request ${tries}`);
1717

18-
await delay(30000);
18+
await delay(15000);
1919
await request(postOpts);
2020
} catch (e) {
2121
log('Failed...');

codefresh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ steps:
2626
type: composition
2727
title: Running Integration Tests
2828
description: Running integration tests with kafka
29-
composition: docker-compose.ci-integration.yml
29+
composition: ./docker-compose.ci-integration.yml
3030
composition_candidates:
3131
integration_tests:
3232
image: ${{BuildDockerImage}}

docker-compose.ci-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- zookeeper
99
- schema-registry
1010
kafka:
11-
image: parkhubprime/pk-confluent-kafka:3.3.0
11+
image: quay.io/parkhubprime/pk-confluent-kafka:3.3.0
1212
hostname: kafka
1313
depends_on:
1414
- zookeeper
@@ -19,7 +19,7 @@ services:
1919
KAFKA_JMX_PORT: 9999
2020
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
2121
zookeeper:
22-
image: parkhubprime/pk-confluent-zookeeper:3.3.0
22+
image: quay.io/parkhubprime/pk-confluent-zookeeper:3.3.0
2323
hostname: zookeeper
2424
environment:
2525
ZOOKEEPER_REPLICAS: 1

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
- ./:/home/app
1313
- /home/app/node_modules
1414
kafka:
15-
image: parkhubprime/pk-confluent-kafka:3.3.0
15+
image: quay.io/parkhubprime/pk-confluent-kafka:3.3.0
1616
hostname: kafka
1717
depends_on:
1818
- zookeeper
@@ -26,7 +26,7 @@ services:
2626
KAFKA_JMX_PORT: 9999
2727
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
2828
zookeeper:
29-
image: parkhubprime/pk-confluent-zookeeper:3.3.0
29+
image: quay.io/parkhubprime/pk-confluent-zookeeper:3.3.0
3030
hostname: zookeeper
3131
ports:
3232
- 2181:2181

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const irisProto = {
4848
/**
4949
* Creates a new producer.
5050
*/
51-
async createProducer(cfgs: { brokerList: string }): Promise<any> {
51+
createProducer(cfgs: { brokerList: string }): Promise<any> {
5252
const { brokerList, registry } = this;
5353
const producerCfgs = {
5454
brokerList,
@@ -57,7 +57,7 @@ const irisProto = {
5757

5858
log('Creating new producer with configurations %O', producerCfgs);
5959

60-
const initiatedProducer = await producer({
60+
const initiatedProducer = producer({
6161
producerCfgs,
6262
registry
6363
});
@@ -71,7 +71,7 @@ const irisProto = {
7171
/**
7272
* Creates a new consumer.
7373
*/
74-
async createConsumer(cfgs: { brokerList: string }): Promise<any> {
74+
createConsumer(cfgs: { brokerList: string }): Promise<any> {
7575
const { brokerList, registry } = this;
7676
const consumerCfgs = {
7777
brokerList,
@@ -80,7 +80,7 @@ const irisProto = {
8080

8181
log('Creating new consumer with configurations %O', consumerCfgs);
8282

83-
const initiatedConsumer = await consumer({
83+
const initiatedConsumer = consumer({
8484
consumerCfgs,
8585
registry
8686
});

0 commit comments

Comments
 (0)