Skip to content

Commit 44bb88a

Browse files
committed
fix model.update(), change to ISO dates
1 parent ce933a5 commit 44bb88a

File tree

15 files changed

+30
-49
lines changed

15 files changed

+30
-49
lines changed

src/adapters/controllers/delete-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function deleteModelFactory (removeModel) {
1212
return {
1313
headers: {
1414
'Content-Type': 'application/json',
15-
'Last-Modified': new Date().toUTCString()
15+
'Last-Modified': new Date().toISOString()
1616
},
1717
statusCode: 201,
1818
body: { modelId: model.id }

src/adapters/controllers/live-rollout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function makeLiveRollout (hotDeploy) {
1717
return {
1818
headers: {
1919
'Content-Type': 'application/json',
20-
'Last-Modified': new Date().toUTCString()
20+
'Last-Modified': new Date().toISOString()
2121
},
2222
statusCode: 200,
2323
body: { result }

src/adapters/controllers/live-update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function makeLiveUpdate (hotReload) {
1616
return {
1717
headers: {
1818
'Content-Type': 'application/json',
19-
'Last-Modified': new Date().toUTCString()
19+
'Last-Modified': new Date().toISOString()
2020
},
2121
statusCode: 200,
2222
body: { fn: liveUpdate.name, result }

src/adapters/controllers/patch-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function patchModelFactory (editModel) {
1818
return {
1919
headers: {
2020
'Content-Type': 'application/json',
21-
'Last-Modified': new Date().toUTCString()
21+
'Last-Modified': new Date().toISOString()
2222
},
2323
statusCode: 201,
2424
body: { modelId: model.id }

src/adapters/controllers/post-invoke-port.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function anyInvokePortFactory (invokePort) {
1919
return {
2020
headers: {
2121
'Content-Type': 'application/json',
22-
'Last-Modified': new Date().toUTCString()
22+
'Last-Modified': new Date().toISOString()
2323
},
2424
statusCode: 201,
2525
body: { ...result }
@@ -38,4 +38,4 @@ export default function anyInvokePortFactory (invokePort) {
3838
}
3939
}
4040
}
41-
}
41+
}

src/adapters/controllers/post-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function postModelFactory (createModel) {
1818
return {
1919
headers: {
2020
'Content-Type': 'application/json',
21-
'Last-Modified': new Date().toUTCString()
21+
'Last-Modified': new Date().toISOString()
2222
},
2323
statusCode: 201,
2424
body: { modelId: model.id }

src/domain/make-ports.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const TIMEOUTSECONDS = 10
1313
const MAXRETRY = 5
1414

1515
function getTimerArgs (args = null) {
16-
const timerArg = { calledByTimer: new Date().toUTCString() }
16+
const timerArg = { calledByTimer: new Date().toISOString() }
1717
if (args) return [...args, timerArg]
1818
return [timerArg]
1919
}
@@ -155,7 +155,7 @@ async function updatePortFlow (model, port) {
155155
const updateModel = this.equals(model) ? model : this
156156
return updateModel.update(
157157
{
158-
[updateModel.getKey('portFlow')]: [...updateModel.getPortFlow(), port]
158+
[updateModel.getKey('portFlow')]: [...this.getPortFlow(), port]
159159
},
160160
false
161161
)
@@ -189,13 +189,10 @@ export default function makePorts (ports, adapters, broker, datasource) {
189189
const portConf = ports[port]
190190
const disabled = portConf.disabled || !adapters[port]
191191

192-
// Listen for event that will invoke this port
193-
const rememberPort = addPortListener(
194-
portName,
195-
portConf,
196-
broker,
197-
datasource
198-
)
192+
// dont listen on a disabled port
193+
const rememberPort = disabled
194+
? false
195+
: addPortListener(portName, portConf, broker, datasource)
199196

200197
/**
201198
*
@@ -264,7 +261,9 @@ export default function makePorts (ports, adapters, broker, datasource) {
264261
// check if the port defines breaker thresholds
265262
const thresholds = portConf.circuitBreaker
266263

264+
// call port without breaker (normal for inbound)
267265
if (!thresholds) return portFn.apply(this, args)
266+
268267
/**
269268
* the circuit breaker instance
270269
* @type {import('./circuit-breaker').breaker}

src/domain/mixins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const toSymbol = keyMap => o => {
7777
* @param {"utc"|"iso"} format
7878
*/
7979
export const fromTimestamp = (timestamps, format = 'utc') => o => {
80-
const formats = { utc: 'toUTCString', iso: 'toISOString' }
80+
const formats = { utc: 'toISOString', iso: 'toISOString' }
8181
const fn = formats[format]
8282

8383
if (!fn) {

src/domain/model.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,20 @@ const Model = (() => {
263263

264264
/**
265265
* Concurrency strategy is to merge changes with
266-
* last saved copy; so {@link changes} should include
266+
* zthe current instance; so {@link changes} should include
267267
* only the subset of properties that are changing.
268268
* Concomitant strategy is to use `Symbol`s to
269-
* avoid conflict, which requires a custom
269+
* avoid conflict, which may require a custom
270270
* {@link Serializer} for network and storage
271-
* transmission. If conflict does occur , last
271+
* handling. If conflict does occur, last
272272
* one in wins.
273273
*
274274
* @param {object} changes - object containing updated props
275275
* @param {boolean} validate - run validation by default
276276
* @returns {Promise<Model>}
277277
*/
278278
async update (changes, validate = true) {
279-
const lastsaved = datasource.findSync(this[ID]) || {}
280-
const mergedata = { ...lastsaved, ...this }
281-
const validated = validateUpdates(mergedata, changes, validate)
279+
const validated = validateUpdates(this, changes, validate)
282280
const timestamp = { ...validated, [UPDATETIME]: Date.now() }
283281

284282
await datasource.save(this[ID], timestamp)
@@ -291,18 +289,7 @@ const Model = (() => {
291289
/**
292290
* Synchronous version of {@link Model.update}.
293291
* Only updates cache. External storage is
294-
* not updated and no event is sent.
295-
*
296-
* Useful for:
297-
* - immediate cache update
298-
* - controlling when/if event is sent
299-
* - calling external storage with custom adapter
300-
*
301-
* Consider situations in which the point is not
302-
* to persist data, but to share it with other
303-
* application components, as is done in workflow
304-
* or between local related model threads, which
305-
* use shared memory.
292+
* not updated
306293
*
307294
* @param {*} changes
308295
* @param {boolean} validate

src/domain/thread-pool.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ export class ThreadPool extends EventEmitter {
466466
errorRateTolerance: this.errorRateThreshold(),
467467
errors: this.errorCount(),
468468
deployments: this.deploymentCount(),
469-
since: new Date(this.startTime).toUTCString()
469+
since: new Date(this.startTime).toISOString()
470470
}
471471
}
472472

@@ -751,12 +751,7 @@ const ThreadPoolFactory = (() => {
751751

752752
const facade = {
753753
async runJob (jobName, jobData, modelName) {
754-
return getPool(poolName, options).runJob(
755-
jobName,
756-
jobData,
757-
modelName,
758-
759-
)
754+
return getPool(poolName, options).runJob(jobName, jobData, modelName)
760755
},
761756
status () {
762757
return getPool(poolName, options).status()

0 commit comments

Comments
 (0)