Skip to content

Commit

Permalink
Show debug output for avro schemas during dry run (#84)
Browse files Browse the repository at this point in the history
* make debug output for avro schemas even during dry run

* remove unneeded whitespace
  • Loading branch information
chuck-alt-delete authored Mar 20, 2023
1 parent 5a970ec commit 843b30a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/dataGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default async function dataGenerator({

if (iteration == 0) {
await producer?.prepare(megaRecord);
if (global.debug && global.dryRun && format == 'avro') {
let avroSchemas = await AvroFormat.getAvroSchemas(megaRecord);
}
}

for (const topic in megaRecord) {
Expand Down
8 changes: 4 additions & 4 deletions src/formats/avroFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AvroFormat implements OutputFormat {
this.registry = registry;
}

private nameHook() {
private static nameHook() {
let index = 0;
return function (schema, opts) {
switch (schema.type) {
Expand All @@ -48,7 +48,7 @@ export class AvroFormat implements OutputFormat {
}

// @ts-ignore
async getAvroSchemas(megaRecord: any) {
static async getAvroSchemas(megaRecord: any) {
let avroSchemas = {};
for (let topic in megaRecord) {
// @ts-ignore
Expand All @@ -59,7 +59,7 @@ export class AvroFormat implements OutputFormat {
if (global.debug) {
alert({
type: `success`,
name: `Avro Schema:`,
name: `Avro Schema for topic ${topic}:`,
msg: `\n ${JSON.stringify(avroSchema, null, 2)}`
});
}
Expand All @@ -70,7 +70,7 @@ export class AvroFormat implements OutputFormat {
}

async register(megaRecord: any): Promise<void> {
const avroSchemas = await this.getAvroSchemas(megaRecord);
const avroSchemas = await AvroFormat.getAvroSchemas(megaRecord);
for (const topic in avroSchemas) {
let options = { subject: `${topic}-value` }
let avroSchema = avroSchemas[topic]
Expand Down

0 comments on commit 843b30a

Please sign in to comment.