Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kafka-client/src/events/provider/kafka/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export class Topic {
offsets: [{
topic: this.name,
partition: 0,
offset: offsetValue
offset: BigInt(offsetValue)
}],
}).then(stream => {
this.provider.logger.info(`Consumer for topic '${this.name}' subscribed`);
Expand Down
30 changes: 14 additions & 16 deletions packages/resource-base-interface/src/experimental/WorkerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,27 +342,25 @@ export abstract class WorkerBase {
await this.events.start();
this.offsetStore = new OffsetStore(this.events, this.cfg, this.logger);

await Promise.all(Object.entries(kafkaCfg.topics).map(async ([key, value]: any[]) => {
for (const [key, value] of Object.entries<any>(kafkaCfg.topics ?? {})) {
const topicName = value.topic;
const topic = await this.events.topic(topicName);
const offsetValue = await this.offsetStore.getOffset(topicName);
this.logger?.verbose('subscribing to topic with offset value', topicName, offsetValue);
Object.entries(value.events as { [key: string]: string } ?? {}).forEach(
([eventName, handler]) => {
const i = handler.lastIndexOf('.');
const name = handler.slice(0, i);
const serviceName = serviceNames?.[name] ?? name;
const functionName = handler.slice(i + 1);
this.eventHandlers.set(eventName, this.bindHandler(serviceName, functionName));
topic.on(
eventName as string,
this.eventHandlers.get(eventName),
{ startingOffset: offsetValue }
);
}
);
for (const [eventName, handler] of Object.entries<string>(value.events ?? {})) {
const i = handler.lastIndexOf('.');
const name = handler.slice(0, i);
const serviceName = serviceNames?.[name] ?? name;
const functionName = handler.slice(i + 1);
this.eventHandlers.set(eventName, this.bindHandler(serviceName, functionName));
await topic.on(
eventName as string,
this.eventHandlers.get(eventName),
{ startingOffset: BigInt(offsetValue) }
);
}
this.topics.set(key, topic);
}));
}
}
protected async bindScheduledJobs() {
const job_config = this.cfg.get('scs-jobs');
Expand Down
Loading