Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Synchronous event sourcing with new runner (#9742)
Browse files Browse the repository at this point in the history
* add runner API

* licenses

* basically working

* more bugs and test cases

* run all effects upon mount

* fix tests

* abstract behind system definitions

* benchmark

* start changing how runners run wrt event source state

* update event sourcing to run synchronous callback on state

* fix failing tests, standardize mocha config, make server-core tests run after all other tests to avoid colliding with instanceserver tests

* cleanup

* replace runner with synchronous flushing of reactor container

* license

* cleanup logs
  • Loading branch information
HexaField authored Feb 14, 2024
1 parent cd9908d commit 542da83
Show file tree
Hide file tree
Showing 32 changed files with 672 additions and 232 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"publish": "lerna publish from-package --yes --registry https://registry.npmjs.org",
"publish-npm": "lerna publish from-package --yes --no-verify-access --ignore-scripts --registry https://registry.npmjs.org",
"publish-github": "lerna publish from-package --yes --no-verify-access --ignore-scripts --registry https://npm.pkg.github.com",
"test": "cross-env TEST=true lerna run --scope '@etherealengine/*' test && lerna run --ignore '@etherealengine/*' test",
"test": "cross-env TEST=true lerna run --scope '@etherealengine/*' --ignore '@etherealengine/server-core' test && lerna run --scope '@etherealengine/server-core' test && lerna run --ignore '@etherealengine/*' test",
"test-e2e": "ts-node --swc scripts/run_e2e_tests.ts",
"test:ci": "cpy --no-overwrite --rename=.env.local '.env.local.default' . && cross-env CI=true npm run test",
"validate": "npm run lint && lerna run validate",
Expand Down
8 changes: 5 additions & 3 deletions packages/client-core/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: false,
spec: ['**/*.test.*'],
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts',
'tsx'
Expand All @@ -41,5 +43,5 @@ module.exports = {
exit: true,
recursive: true,
jobs: '1',
timeout: '20000'
timeout: '60000'
};
20 changes: 14 additions & 6 deletions packages/client/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,24 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: true,
spec: ['tests/**/*.test.ts'],
parallel: false,
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts'
]
};
'ts',
'tsx'
],
bail: true,
exit: true,
recursive: true,
jobs: '1',
timeout: '60000'
};
16 changes: 10 additions & 6 deletions packages/common/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: true,
spec: ['tests/**/*.test.ts'],
parallel: false,
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts'
'ts',
'tsx'
],
bail: true,
exit: true,
recursive: true,
jobs: '1',
timeout: '300000'
};
timeout: '60000'
};
16 changes: 10 additions & 6 deletions packages/ecs/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,24 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: true,
spec: ['./**/*.test.ts'],
parallel: false,
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts'
'ts',
'tsx'
],
bail: true,
exit: true,
recursive: true,
jobs: '1',
timeout: '300000'
};
timeout: '60000'
};
2 changes: 1 addition & 1 deletion packages/ecs/src/ComponentFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ export const setComponent = <C extends Component>(
// startTransition(() => {
Component.onSet(entity, Component.stateMap[entity]!, args as Readonly<SerializedComponentType<C>>)
const root = Component.reactorMap.get(entity)
if (!root?.isRunning) root?.run()
root?.run(true)
// })
}

Expand Down
9 changes: 2 additions & 7 deletions packages/ecs/src/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Ethereal Engine. All Rights Reserved.
import type { UserID } from '@etherealengine/common/src/schema.type.module'
import * as Hyperflux from '@etherealengine/hyperflux'
import { createHyperStore, getState } from '@etherealengine/hyperflux'
import { HyperFlux, HyperStore } from '@etherealengine/hyperflux/functions/StoreFunctions'
import { HyperFlux, HyperStore, disposeStore } from '@etherealengine/hyperflux/functions/StoreFunctions'
import * as bitECS from 'bitecs'

import type { FeathersApplication } from '@feathersjs/feathers'
Expand Down Expand Up @@ -123,12 +123,7 @@ export async function destroyEngine() {
removeQuery(query.query)
}

const activeReactors = [] as Promise<void>[]

for (const reactor of Engine.instance.store.activeReactors) {
activeReactors.push(reactor.stop())
}
await Promise.all(activeReactors)
await disposeStore()

/** @todo include in next bitecs update */
// bitecs.deleteWorld(Engine.instance)
Expand Down
1 change: 1 addition & 0 deletions packages/ecs/src/SystemFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface System {
* Defaults to 'variable'.
*/
timeStep: number | 'variable'
/** @deprecated use defineState reactor instead */
reactor?: FC
insert?: InsertSystem
preSystems: SystemUUID[]
Expand Down
11 changes: 5 additions & 6 deletions packages/editor/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: false,
spec: [
'**/*.test.ts',
'**/*.test.tsx'
],
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts',
'tsx'
Expand All @@ -44,5 +43,5 @@ module.exports = {
exit: true,
recursive: true,
jobs: '1',
timeout: '20000'
timeout: '60000'
};
15 changes: 9 additions & 6 deletions packages/engine/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,24 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/


module.exports = {
failZero: false,
parallel: true,
spec: ['**/*.test.ts', '**/*.test.tsx'],
parallel: false,
require: [
'tests/mocha.env', // init env here
'jsdom-global/register'
],
spec: [
'./**/*.test.ts',
'./**/*.test.tsx'
],
extension: [
'ts'
'ts',
'tsx'
],
bail: true,
exit: true,
recursive: true,
jobs: '1',
timeout: '20000'
};
timeout: '60000'
};
Loading

0 comments on commit 542da83

Please sign in to comment.