Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2019-12-09 14:03:47 -0500
committerAustin Schaffer <austin.schaffer@ryansg.com>2019-12-12 10:27:09 -0500
commite885026e0a1ecf1e21e821fb50fe5d1a46537664 (patch)
tree0003c2692ffdbbff0ea93e735c420852c175978a /src
parent4383d15c5a375b7e189888aa22f198557997db47 (diff)
downloadliza-e885026e0a1ecf1e21e821fb50fe5d1a46537664.tar.gz
liza-e885026e0a1ecf1e21e821fb50fe5d1a46537664.tar.bz2
liza-e885026e0a1ecf1e21e821fb50fe5d1a46537664.zip
DeltaPublisher: Remove parsing from constructor
Diffstat (limited to 'src')
-rw-r--r--src/system/DeltaPublisher.ts17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/system/DeltaPublisher.ts b/src/system/DeltaPublisher.ts
index 5def3a9..9b05114 100644
--- a/src/system/DeltaPublisher.ts
+++ b/src/system/DeltaPublisher.ts
@@ -30,16 +30,10 @@ import { AmqpError } from '../error/AmqpError';
import { AvroEncoderCtr } from './avro/AvroFactory';
import { AmqpConnection } from './amqp/AmqpConnection';
-import { AvroSchema, parse } from "avro-js";
+import { AvroSchema } from "avro-js";
export class DeltaPublisher implements AmqpPublisher
{
- /** The avro schema */
- private _schema: AvroSchema;
-
- /** The path to the avro schema */
- readonly SCHEMA_PATH = __dirname + '/avro/schema.avsc';
-
/** A mapping of which delta type translated to which avro event */
readonly DELTA_MAP: Record<string, string> = {
data: 'STEP_SAVE',
@@ -58,11 +52,10 @@ export class DeltaPublisher implements AmqpPublisher
constructor(
private readonly _emitter: EventEmitter,
private readonly _ts_ctr: () => UnixTimestamp,
- private readonly _encoder_ctr: AvroEncoderCtr,
+ private readonly _encoder_ctor: AvroEncoderCtr,
private readonly _conn: AmqpConnection,
- ) {
- this._schema = parse( this.SCHEMA_PATH );
- }
+ private readonly _schema: AvroSchema,
+ ) {}
/**
@@ -263,7 +256,7 @@ export class DeltaPublisher implements AmqpPublisher
{
this._assertValidAvro( this._schema, data )
- const encoder = this._encoder_ctr( this._schema )
+ const encoder = this._encoder_ctor( this._schema )
encoder.on('data', ( buf: Buffer ) => { bufs.push( buf ) } )
encoder.on('error', ( err: Error ) => { reject( err ); } )