Skip to content

Commit

Permalink
bugfix-RND-462-create-the-same-memphis-instance-in-js-sdk (#256)
Browse files Browse the repository at this point in the history
* add createMemphisInstance

* update readme
  • Loading branch information
shohamroditimemphis authored Jan 16, 2024
1 parent da31b77 commit 4cab17f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1066,3 +1066,9 @@ await consumer.destroy();
```js
memphisConnection.isConnected();
```

### Create memphis instance

```js
const memphisInstance = createMemphisInstance()
```
10 changes: 7 additions & 3 deletions src/memphis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ class Memphis {
partitions = createRes.partitions_update.partitions_list;
}
this.stationPartitions.set(internal_station, partitions);

const producer = new Producer(this, producerName, stationName, realName, partitions);
await this._scemaUpdatesListener(stationName, createRes.schema_update);
this.setCachedProducer(producer);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ class Memphis {
}
}
this.stationPartitions.set(internal_station, partitions);

// the least possible value for batchMaxTimeToWaitMs is 100
batchMaxTimeToWaitMs = batchMaxTimeToWaitMs < 100 ? 100 : batchMaxTimeToWaitMs;
const consumer = new Consumer(
Expand All @@ -1026,7 +1026,7 @@ class Memphis {
partitions,
consumerPartitionKey,
consumerPartitionNumber
);
);
await this._scemaUpdatesListener(stationName, createRes.schema_update);
this.setCachedConsumer(consumer);

Expand Down Expand Up @@ -1428,6 +1428,10 @@ export class RoundRobinProducerConsumerGenerator {
}
}

export const createMemphisInstance = () => {
return new Memphis();
}

@Injectable({})
export class MemphisService extends Memphis { }

Expand Down

0 comments on commit 4cab17f

Please sign in to comment.