Skip to content

Commit

Permalink
feat: JOIN-33238 update pubsub lib with mandatory schema in publisher…
Browse files Browse the repository at this point in the history
… factory

BREAKING CHANGE: schema is now mandatory for PublisherFactory
  • Loading branch information
eugene-taran committed Jun 30, 2023
1 parent 0a48e4b commit dc994ed
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/pubsub/src/PublisherFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ export interface IPublisher<T> {
export class PublisherFactory<TypeMap> {
private readonly client: PubSub

constructor(private readonly logger: ILogger, private readonly avroSchemas: Record<keyof TypeMap, { writer: object, reader: object }>) {
this.client = new PubSub()
}

public getPublisher<Topic extends keyof TypeMap> (topic: Topic): IPublisher<TypeMap[Topic]> {
return new Publisher(topic.toString(), this.client, this.logger, this.avroSchemas[topic])
}
}

/**
* @deprecated should be used only when migration of the events/commands is not possible
*/
export class PublisherFactorySchemaless<TypeMap> {
private readonly client: PubSub

constructor(private readonly logger: ILogger, private readonly avroSchemas?: Record<keyof TypeMap, { writer: object, reader: object }>) {
this.client = new PubSub()
}
Expand Down

0 comments on commit dc994ed

Please sign in to comment.