1
0
Fork 0

[DEV-6730] Store concluding_save with the reverse delta

master
Austin Schaffer 2020-01-14 13:01:17 -05:00
parent 103c06da39
commit 61b66c24a3
7 changed files with 59 additions and 35 deletions

View File

@ -53,9 +53,10 @@ export type DeltaResult<T> = { [K in keyof T]: DeltaDatum<T[K]> | null };
/** Complete delta type */ /** Complete delta type */
export type Delta<T> = { export type Delta<T> = {
type: DeltaType, type: DeltaType,
timestamp: UnixTimestamp, timestamp: UnixTimestamp,
data: DeltaResult<T>, concluding_save: boolean,
data: DeltaResult<T>,
} }

View File

@ -1144,9 +1144,10 @@ module.exports = Class( 'Server' )
{ {
try try
{ {
var rdelta_data; var rdelta_data;
var parsed_data = JSON.parse( post_data.data ); var parsed_data = JSON.parse( post_data.data );
var bucket = quote.getBucket(); var bucket = quote.getBucket();
const concluding_save = post_data.concluding_save;
const { filtered, dapis, meta_clear, rdiff } = const { filtered, dapis, meta_clear, rdiff } =
server._dataProcessor.processDiff( server._dataProcessor.processDiff(
@ -1158,8 +1159,9 @@ module.exports = Class( 'Server' )
{ {
rdelta_data = { rdelta_data = {
"rdelta.data": { "rdelta.data": {
data: rdiff, data: rdiff,
timestamp: Math.round( concluding_save: ( concluding_save === 'true' ),
timestamp: Math.round(
new Date().getTime() / 1000 new Date().getTime() / 1000
), ),
} }

View File

@ -264,8 +264,9 @@ export class RatingService
const save_data = { ratedata: data }; const save_data = { ratedata: data };
const rdelta_data = { const rdelta_data = {
"rdelta.ratedata": { "rdelta.ratedata": {
data: this._createDelta( data, quote_data ), data: this._createDelta( data, quote_data ),
timestamp: cur_date concluding_save: false,
timestamp: cur_date,
}, },
}; };

View File

@ -105,12 +105,26 @@ export class V1MessageWriter implements MessageWriter
const last_update_ms = { "long": meta.lastUpdate * 1000 }; const last_update_ms = { "long": meta.lastUpdate * 1000 };
const ts_ms = ts * 1000; const ts_ms = ts * 1000;
let step = null;
if( delta.concluding_save === true )
{
step = {
EventStep: {
transition: 'END',
src: '',
dest: '',
}
}
}
return { return {
event: { event: {
id: event_id, id: event_id,
ts: ts_ms, ts: ts_ms,
actor: 'SERVER', actor: 'SERVER',
step: null, step: step,
}, },
document: { document: {
id: meta.id, id: meta.id,
@ -266,4 +280,4 @@ export class V1MessageWriter implements MessageWriter
return data_formatted; return data_formatted;
} }
} }

View File

@ -468,6 +468,7 @@ function getStubs()
data: { data: {
_unavailable_all: [ undefined ] _unavailable_all: [ undefined ]
}, },
concluding_save: false,
timestamp: 123 timestamp: 123
} }
}; };

View File

@ -459,9 +459,10 @@ describe( 'system.DeltaProcessor', () =>
rdelta: { rdelta: {
data: [ data: [
{ {
data: { foo: [ 'first_bar' ] }, data: { foo: [ 'first_bar' ] },
timestamp: <UnixTimestamp>123123, timestamp: <UnixTimestamp>123123,
type: 'data', type: 'data',
concluding_save: false,
} }
], ],
ratedata: [], ratedata: [],
@ -583,9 +584,10 @@ describe( 'system.DeltaProcessor', () =>
rdelta: { rdelta: {
data: [ data: [
{ {
data: { foo: [ 'first_bar' ] }, data: { foo: [ 'first_bar' ] },
timestamp: <UnixTimestamp>123123, timestamp: <UnixTimestamp>123123,
type: 'data', type: 'data',
concluding_save: false,
} }
], ],
ratedata: [], ratedata: [],
@ -603,9 +605,10 @@ describe( 'system.DeltaProcessor', () =>
rdelta: { rdelta: {
data: [ data: [
{ {
data: { foo: [ 'first_bar' ] }, data: { foo: [ 'first_bar' ] },
timestamp: <UnixTimestamp>123123, timestamp: <UnixTimestamp>123123,
type: 'data', type: 'data',
concluding_save: false,
} }
], ],
ratedata: [], ratedata: [],

View File

@ -189,17 +189,12 @@ describe( 'system.V1MessageWriter', () =>
if ( valid ) if ( valid )
{ {
// return expect( result ).to.eventually.deep.equal( return expect( result ).to.eventually.deep.equal(
// Buffer.from( '' ) Buffer.from( '' )
// ) )
// .then( b => .then( b =>
// {
// expect( typeof(b) ).to.equal( 'object' );
// } );
return result.catch( e =>
{ {
console.log( 'avroerror: ', e ); expect( typeof(b) ).to.equal( 'object' );
expect.fail();
} ); } );
} }
else else
@ -396,9 +391,10 @@ describe( 'system.V1MessageWriter', () =>
}; };
const delta = <Delta<any>>{ const delta = <Delta<any>>{
type: <DeltaType>'data', type: <DeltaType>'data',
timestamp: <UnixTimestamp>123123123, timestamp: <UnixTimestamp>123123123,
data: <DeltaResult<any>>{}, data: <DeltaResult<any>>{},
concluding_save: true,
}; };
const expected = { const expected = {
@ -406,7 +402,13 @@ describe( 'system.V1MessageWriter', () =>
id: 'STEP_SAVE', id: 'STEP_SAVE',
ts: ts * 1000, ts: ts * 1000,
actor: 'SERVER', actor: 'SERVER',
step: null, step: {
EventStep: {
transition: 'END',
src: '',
dest: '',
},
},
}, },
document: { document: {
id: doc_id, id: doc_id,