Skip to content

Commit

Permalink
Remove duplicate method and use existing instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Brinch committed Jul 12, 2021
1 parent 68cc9eb commit a47dd57
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/SchemaRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class SchemaRegistry {
const references = await this.registerReferences(opts, helper, confluentSchema)
const referenceSchemas = await Promise.all(
references.map(async reference => {
return this.getSchemaForSubject(reference.subject, reference.version)
return this.getSchema(await this.getRegistryId(reference.subject, reference.version))
}),
)

Expand Down Expand Up @@ -194,15 +194,6 @@ export default class SchemaRegistry {
return registeredSchema
}

public async getSchemaForSubject(subject: string, version: number): Promise<Schema | AvroSchema> {
const response = await this.api.Subject.version({
subject,
version,
})
const schema: { id: number } = response.data()
return await this.getSchema(schema.id)
}

public async getSchema(registryId: number): Promise<Schema | AvroSchema> {
const schema = this.cache.getSchema(registryId)

Expand All @@ -225,7 +216,7 @@ export default class SchemaRegistry {

const referenceSchemas = await Promise.all(
(foundSchema.references || []).map(async reference => {
return this.getSchemaForSubject(reference.subject, reference.version)
return this.getSchema(await this.getRegistryId(reference.subject, reference.version))
}),
)

Expand Down

0 comments on commit a47dd57

Please sign in to comment.