Pass along information about whether a save step was the last one
commit
09a84e7caf
|
@ -53,9 +53,10 @@ export type DeltaResult<T> = { [K in keyof T]: DeltaDatum<T[K]> | null };
|
|||
|
||||
/** Complete delta type */
|
||||
export type Delta<T> = {
|
||||
type: DeltaType,
|
||||
timestamp: UnixTimestamp,
|
||||
data: DeltaResult<T>,
|
||||
type: DeltaType,
|
||||
timestamp: UnixTimestamp,
|
||||
concluding_save: boolean,
|
||||
data: DeltaResult<T>,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1563,7 +1563,11 @@ module.exports = Class( 'Client' )
|
|||
|
||||
// transport used to transfer the bucket data to the server, prohibiting
|
||||
// callback aborts (to ensure that we can handle failures ourselves)
|
||||
var transport = this._createBucketTransport( step_id, true );
|
||||
var transport = this._createBucketTransport(
|
||||
step_id,
|
||||
true,
|
||||
event.concluding_save
|
||||
);
|
||||
|
||||
var finish, timeout;
|
||||
function dosave()
|
||||
|
@ -1712,11 +1716,16 @@ module.exports = Class( 'Client' )
|
|||
},
|
||||
|
||||
|
||||
'private _createBucketTransport': function( step_id, prohibit_abort )
|
||||
{
|
||||
'private _createBucketTransport': function(
|
||||
step_id,
|
||||
prohibit_abort,
|
||||
concluding_save
|
||||
){
|
||||
return this._factory.createDataBucketTransport(
|
||||
this._quote.getId(), step_id,
|
||||
this._createDataProxy( jQuery, prohibit_abort )
|
||||
this._quote.getId(),
|
||||
step_id,
|
||||
this._createDataProxy( jQuery, prohibit_abort ),
|
||||
concluding_save
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -162,11 +162,17 @@ module.exports = Class( 'ClientDependencyFactory',
|
|||
createStagingBucketDiscard: StagingBucketAutoDiscard,
|
||||
|
||||
|
||||
createDataBucketTransport: function ( quote_id, step_id, proxy )
|
||||
createDataBucketTransport: function (
|
||||
quote_id,
|
||||
step_id,
|
||||
proxy,
|
||||
concluding_save
|
||||
)
|
||||
{
|
||||
return XhttpQuoteTransport(
|
||||
( quote_id + '/step/' + step_id + '/post' ),
|
||||
proxy
|
||||
proxy,
|
||||
concluding_save
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
@ -42,19 +42,27 @@ module.exports = Class( 'XhttpQuoteTransport' )
|
|||
*/
|
||||
'private _url': '',
|
||||
|
||||
/**
|
||||
* Indicates a concluding save
|
||||
* @type {boolean}
|
||||
*/
|
||||
'private _concluding_save': false,
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new quote transport with the destination URL and proxy
|
||||
*
|
||||
* @param {string} url destination URL
|
||||
* @param {HttpDataProxy} proxy proxy to use for transfer
|
||||
* @param {string} url destination URL
|
||||
* @param {HttpDataProxy} proxy proxy to use for transfer
|
||||
* @param {boolean} concluding_save concluding save
|
||||
*
|
||||
* @return {undefined}
|
||||
*/
|
||||
'public __construct': function( url, proxy )
|
||||
'public __construct': function( url, proxy, concluding_save )
|
||||
{
|
||||
this._url = ''+( url );
|
||||
this._proxy = proxy;
|
||||
this._url = ''+( url );
|
||||
this._proxy = proxy;
|
||||
this._concluding_save = concluding_save;
|
||||
},
|
||||
|
||||
|
||||
|
@ -80,7 +88,9 @@ module.exports = Class( 'XhttpQuoteTransport' )
|
|||
var data = _self.getBucketDataJson( bucket );
|
||||
|
||||
// post the data
|
||||
_self._proxy.post( _self._url, { data: data },
|
||||
_self._proxy.post(
|
||||
_self._url,
|
||||
{ data: data, concluding_save: _self._concluding_save },
|
||||
function( data, error )
|
||||
{
|
||||
if ( typeof callback === 'function' )
|
||||
|
|
|
@ -1144,9 +1144,10 @@ module.exports = Class( 'Server' )
|
|||
{
|
||||
try
|
||||
{
|
||||
var rdelta_data;
|
||||
var parsed_data = JSON.parse( post_data.data );
|
||||
var bucket = quote.getBucket();
|
||||
var rdelta_data;
|
||||
var parsed_data = JSON.parse( post_data.data );
|
||||
var bucket = quote.getBucket();
|
||||
const concluding_save = post_data.concluding_save;
|
||||
|
||||
const { filtered, dapis, meta_clear, rdiff } =
|
||||
server._dataProcessor.processDiff(
|
||||
|
@ -1158,8 +1159,9 @@ module.exports = Class( 'Server' )
|
|||
{
|
||||
rdelta_data = {
|
||||
"rdelta.data": {
|
||||
data: rdiff,
|
||||
timestamp: Math.round(
|
||||
data: rdiff,
|
||||
concluding_save: ( concluding_save === 'true' ),
|
||||
timestamp: Math.round(
|
||||
new Date().getTime() / 1000
|
||||
),
|
||||
}
|
||||
|
|
|
@ -264,8 +264,9 @@ export class RatingService
|
|||
const save_data = { ratedata: data };
|
||||
const rdelta_data = {
|
||||
"rdelta.ratedata": {
|
||||
data: this._createDelta( data, quote_data ),
|
||||
timestamp: cur_date
|
||||
data: this._createDelta( data, quote_data ),
|
||||
concluding_save: false,
|
||||
timestamp: cur_date,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -105,12 +105,26 @@ export class V1MessageWriter implements MessageWriter
|
|||
const last_update_ms = { "long": meta.lastUpdate * 1000 };
|
||||
const ts_ms = ts * 1000;
|
||||
|
||||
|
||||
let step = null;
|
||||
|
||||
if( delta.concluding_save === true )
|
||||
{
|
||||
step = {
|
||||
EventStep: {
|
||||
transition: 'END',
|
||||
src: '',
|
||||
dest: '',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
event: {
|
||||
id: event_id,
|
||||
ts: ts_ms,
|
||||
actor: 'SERVER',
|
||||
step: null,
|
||||
step: step,
|
||||
},
|
||||
document: {
|
||||
id: meta.id,
|
||||
|
@ -266,4 +280,4 @@ export class V1MessageWriter implements MessageWriter
|
|||
return data_formatted;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
21
src/ui/Ui.js
21
src/ui/Ui.js
|
@ -934,7 +934,8 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
|
|||
},
|
||||
// no UI update (IE will display a security warning
|
||||
// otherwise)
|
||||
( ( last_step ) ? true : false )
|
||||
last_step,
|
||||
last_step
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1128,20 +1129,24 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
|
|||
return this;
|
||||
}
|
||||
|
||||
var len = this.saveStepHooks.length,
|
||||
step = arguments[0] || this.getCurrentStep(),
|
||||
callback = arguments[1] || function() {},
|
||||
fail_callback = arguments[2] || function() {},
|
||||
immediate = ( ( arguments[3] !== undefined )
|
||||
var len = this.saveStepHooks.length,
|
||||
step = arguments[0] || this.getCurrentStep(),
|
||||
callback = arguments[1] || function() {},
|
||||
fail_callback = arguments[2] || function() {},
|
||||
immediately_save = ( ( arguments[3] !== undefined )
|
||||
? arguments[3]
|
||||
: false
|
||||
),
|
||||
concluding_save = ( ( arguments[4] !== undefined )
|
||||
? !!arguments[4]
|
||||
: false
|
||||
),
|
||||
abort = false;
|
||||
|
||||
var event = {
|
||||
forceCallback: false,
|
||||
errors: [],
|
||||
|
||||
concluding_save: concluding_save,
|
||||
aborted: false,
|
||||
abort: function()
|
||||
{
|
||||
|
@ -1285,7 +1290,7 @@ module.exports = Class( 'Ui' ).extend( EventEmitter,
|
|||
}
|
||||
};
|
||||
|
||||
if ( immediate )
|
||||
if ( immediately_save )
|
||||
{
|
||||
doSave();
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ describe( "XhttpQuoteTransport", () =>
|
|||
bs: [ null ],
|
||||
};
|
||||
|
||||
const concluding_save = true;
|
||||
|
||||
const stub_quote = { visitData: c => c( bucket ) };
|
||||
|
||||
const mock_proxy = {
|
||||
|
@ -66,10 +68,13 @@ describe( "XhttpQuoteTransport", () =>
|
|||
expect( JSON.parse( data.data ) )
|
||||
.to.deep.equal( expected_data );
|
||||
|
||||
expect( JSON.parse( data.concluding_save ) )
|
||||
.to.deep.equal( concluding_save );
|
||||
|
||||
done();
|
||||
},
|
||||
};
|
||||
|
||||
Sut( '', mock_proxy ).send( stub_quote );
|
||||
Sut( '', mock_proxy, concluding_save ).send( stub_quote );
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -468,6 +468,7 @@ function getStubs()
|
|||
data: {
|
||||
_unavailable_all: [ undefined ]
|
||||
},
|
||||
concluding_save: false,
|
||||
timestamp: 123
|
||||
}
|
||||
};
|
||||
|
|
|
@ -459,9 +459,10 @@ describe( 'system.DeltaProcessor', () =>
|
|||
rdelta: {
|
||||
data: [
|
||||
{
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
concluding_save: false,
|
||||
}
|
||||
],
|
||||
ratedata: [],
|
||||
|
@ -583,9 +584,10 @@ describe( 'system.DeltaProcessor', () =>
|
|||
rdelta: {
|
||||
data: [
|
||||
{
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
concluding_save: false,
|
||||
}
|
||||
],
|
||||
ratedata: [],
|
||||
|
@ -603,9 +605,10 @@ describe( 'system.DeltaProcessor', () =>
|
|||
rdelta: {
|
||||
data: [
|
||||
{
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
data: { foo: [ 'first_bar' ] },
|
||||
timestamp: <UnixTimestamp>123123,
|
||||
type: 'data',
|
||||
concluding_save: false,
|
||||
}
|
||||
],
|
||||
ratedata: [],
|
||||
|
|
|
@ -189,17 +189,12 @@ describe( 'system.V1MessageWriter', () =>
|
|||
|
||||
if ( valid )
|
||||
{
|
||||
// return expect( result ).to.eventually.deep.equal(
|
||||
// Buffer.from( '' )
|
||||
// )
|
||||
// .then( b =>
|
||||
// {
|
||||
// expect( typeof(b) ).to.equal( 'object' );
|
||||
// } );
|
||||
return result.catch( e =>
|
||||
return expect( result ).to.eventually.deep.equal(
|
||||
Buffer.from( '' )
|
||||
)
|
||||
.then( b =>
|
||||
{
|
||||
console.log( 'avroerror: ', e );
|
||||
expect.fail();
|
||||
expect( typeof(b) ).to.equal( 'object' );
|
||||
} );
|
||||
}
|
||||
else
|
||||
|
@ -396,9 +391,10 @@ describe( 'system.V1MessageWriter', () =>
|
|||
};
|
||||
|
||||
const delta = <Delta<any>>{
|
||||
type: <DeltaType>'data',
|
||||
timestamp: <UnixTimestamp>123123123,
|
||||
data: <DeltaResult<any>>{},
|
||||
type: <DeltaType>'data',
|
||||
timestamp: <UnixTimestamp>123123123,
|
||||
data: <DeltaResult<any>>{},
|
||||
concluding_save: true,
|
||||
};
|
||||
|
||||
const expected = {
|
||||
|
@ -406,7 +402,13 @@ describe( 'system.V1MessageWriter', () =>
|
|||
id: 'STEP_SAVE',
|
||||
ts: ts * 1000,
|
||||
actor: 'SERVER',
|
||||
step: null,
|
||||
step: {
|
||||
EventStep: {
|
||||
transition: 'END',
|
||||
src: '',
|
||||
dest: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
document: {
|
||||
id: doc_id,
|
||||
|
|
Loading…
Reference in New Issue