1
0
Fork 0

[DEV-5312] Log quote_id along with doc_id

master
Austin Schaffer 2019-12-17 11:45:52 -05:00
parent ccfd40c64f
commit 542745da8a
6 changed files with 46 additions and 16 deletions

View File

@ -272,8 +272,9 @@ export class MongoTokenDao implements TokenDao
`Unknown token namespace '${ns}' for document '${doc_id}` `Unknown token namespace '${ns}' for document '${doc_id}`
), ),
{ {
doc_id: doc_id, doc_id: doc_id,
ns: ns, quote_id: doc_id,
ns: ns,
} }
) ); ) );
@ -317,8 +318,9 @@ export class MongoTokenDao implements TokenDao
`on document '${doc_id}'` `on document '${doc_id}'`
), ),
{ {
doc_id: doc_id, doc_id: doc_id,
ns: ns, quote_id: doc_id,
ns: ns,
}, },
); );
} }
@ -363,6 +365,7 @@ export class MongoTokenDao implements TokenDao
), ),
{ {
doc_id: doc_id, doc_id: doc_id,
quote_id: doc_id,
ns: ns, ns: ns,
token_id: token_id, token_id: token_id,
}, },

View File

@ -22,6 +22,7 @@
import { DeltaDao } from '../system/db/DeltaDao'; import { DeltaDao } from '../system/db/DeltaDao';
import { DocumentMeta } from '../document/Document'; import { DocumentMeta } from '../document/Document';
import { AmqpPublisher } from './AmqpPublisher'; import { AmqpPublisher } from './AmqpPublisher';
import { context } from '../error/ContextError';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { import {
DeltaType, DeltaType,
@ -122,11 +123,25 @@ export class DeltaProcessor
) )
.then( _ => .then( _ =>
{ {
this._emitter.emit( 'document-processed', { doc_id: meta.id } ); this._emitter.emit(
'document-processed',
{
doc_id: meta.id,
quote_id: meta.id,
},
);
} ) } )
.catch( ( e: Error ) => .catch( ( e: Error ) =>
{ {
this._emitter.emit( 'error', e ); const context_error = context(
e,
{
doc_id: meta.id,
quote_id: meta.id,
},
);
this._emitter.emit( 'error', context_error );
return this._dao.setErrorFlag( meta.id ); return this._dao.setErrorFlag( meta.id );
} ); } );
} }

View File

@ -84,6 +84,7 @@ export class DeltaPublisher implements AmqpPublisher
new AmqpError( 'Error sending message: No channel' ), new AmqpError( 'Error sending message: No channel' ),
{ {
doc_id: meta.id, doc_id: meta.id,
quote_id: meta.id,
delta_type: delta.type, delta_type: delta.type,
delta_ts: delta.timestamp, delta_ts: delta.timestamp,
}, },
@ -104,6 +105,7 @@ export class DeltaPublisher implements AmqpPublisher
new Error ( 'Delta publish failed' ), new Error ( 'Delta publish failed' ),
{ {
doc_id: meta.id, doc_id: meta.id,
quote_id: meta.id,
delta_type: delta.type, delta_type: delta.type,
delta_ts: delta.timestamp, delta_ts: delta.timestamp,
} }
@ -115,7 +117,9 @@ export class DeltaPublisher implements AmqpPublisher
this._emitter.emit( this._emitter.emit(
'delta-publish', 'delta-publish',
{ {
delta: delta, doc_id: meta.id,
quote_id: meta.id,
delta: delta,
exchange: this._conn.getExchangeName(), exchange: this._conn.getExchangeName(),
} }
); );

View File

@ -133,8 +133,9 @@ export class MongoDeltaDao implements DeltaDao
reject( context( reject( context(
new DaoError( 'Error advancing delta index: ' + e ), new DaoError( 'Error advancing delta index: ' + e ),
{ {
doc_id: doc_id, doc_id: doc_id,
type: type, quote_id: doc_id,
type: type,
} }
) ); ) );
return; return;
@ -177,6 +178,7 @@ export class MongoDeltaDao implements DeltaDao
), ),
{ {
doc_id: doc_id, doc_id: doc_id,
quote_id: doc_id,
last_update_ts: last_update_ts, last_update_ts: last_update_ts,
} }
) ); ) );
@ -215,7 +217,8 @@ export class MongoDeltaDao implements DeltaDao
'Failed setting error flag: ' + e 'Failed setting error flag: ' + e
), ),
{ {
doc_id: doc_id, doc_id: doc_id,
quote_id: doc_id,
} }
) ); ) );
return; return;

View File

@ -372,6 +372,7 @@ describe( 'server.token.TokenDao', () =>
`${ns}.tok123`, `${ns}.tok123`,
{ {
doc_id: did, doc_id: did,
quote_id: did,
ns: ns, ns: ns,
token_id: 'tok123', token_id: 'tok123',
}, },
@ -386,8 +387,9 @@ describe( 'server.token.TokenDao', () =>
null, null,
ns, ns,
{ {
doc_id: did, doc_id: did,
ns: ns, quote_id: did,
ns: ns,
}, },
], ],
@ -440,8 +442,9 @@ describe( 'server.token.TokenDao', () =>
null, null,
ns, ns,
{ {
doc_id: did, doc_id: did,
ns: ns, quote_id: did,
ns: ns,
}, },
], ],
@ -454,8 +457,9 @@ describe( 'server.token.TokenDao', () =>
null, null,
ns, ns,
{ {
doc_id: did, doc_id: did,
ns: ns, quote_id: did,
ns: ns,
}, },
], ],
] ).forEach( ( [ label, tok_id, dbresult, expected, fmsg, fcontext ] ) => ] ).forEach( ( [ label, tok_id, dbresult, expected, fmsg, fcontext ] ) =>

View File

@ -123,6 +123,7 @@ describe( 'server.DeltaPublisher', () =>
const expected = { const expected = {
doc_id: meta.id, doc_id: meta.id,
quote_id: meta.id,
delta_type: delta.type, delta_type: delta.type,
delta_ts: delta.timestamp delta_ts: delta.timestamp
} }