Skip to content

Commit d4c34e9

Browse files
authored
Merge pull request #275 from module-federation/release-0-1-0
Release 0 1 0
2 parents 60fa883 + 42dbca9 commit d4c34e9

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

src/domain/datasource-factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ const DsCoreExtensions = superclass =>
144144
*/
145145
stream (list, options) {
146146
return new Promise((resolve, reject) => {
147-
assert.ok(list && options, 'missing m kkkakkk')
147+
assert.ok(list && options, 'missing params')
148148
options.writable.on('error', reject)
149149
options.writable.on('end', resolve)
150150

src/domain/shared-memory.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const MAPSIZE = 2048 * 56
1212
const KEYSIZE = 64
1313
const OBJSIZE = 4056
1414

15-
function logError(x) {
15+
function logError (x) {
1616
const errObj = { msg: 'unexpected datatype', type: typeof x, value: x }
1717
console.error(errObj)
1818
throw new Error(JSON.stringify(errObj))
@@ -24,15 +24,15 @@ const dataType = {
2424
object: x => JSON.stringify(x),
2525
number: x => logError(x),
2626
symbol: x => logError(x),
27-
undefined: x => logError(x),
27+
undefined: x => logError(x)
2828
},
2929
read: {
3030
string: x => JSON.parse(x),
3131
object: x => logError(x),
3232
number: x => logError(x),
3333
symbol: x => logError(x),
34-
undefined: x => logError(x),
35-
},
34+
undefined: x => logError(x)
35+
}
3636
}
3737

3838
/** @typedef {import('./datasource-factory').default} DataSourceFactory */
@@ -46,15 +46,15 @@ const dataType = {
4646
*/
4747
const SharedMemoryMixin = superclass =>
4848
class extends superclass {
49-
constructor(map, name, namespace, options) {
49+
constructor (map, name, namespace, options) {
5050
super(map, name, namespace, options)
5151
}
5252

5353
/**
5454
* @override
5555
* @returns {import('.').Model}
5656
*/
57-
mapSet(id, data) {
57+
mapSet (id, data) {
5858
return this.dsMap.set(id, dataType.write[typeof data](data))
5959
}
6060

@@ -64,7 +64,7 @@ const SharedMemoryMixin = superclass =>
6464
* @param {*} id
6565
* @returns {import('.').Model}
6666
*/
67-
mapGet(id) {
67+
mapGet (id) {
6868
if (!id) {
6969
return console.warn({ fn: this.mapGet.name, msg: 'no id provided' })
7070
}
@@ -92,7 +92,7 @@ const SharedMemoryMixin = superclass =>
9292
* @override
9393
* @returns
9494
*/
95-
mapToArray() {
95+
mapToArray () {
9696
return this.dsMap.map(v =>
9797
isMainThread
9898
? JSON.parse(v)
@@ -104,11 +104,11 @@ const SharedMemoryMixin = superclass =>
104104
* @override
105105
* @returns
106106
*/
107-
mapCount() {
107+
mapCount () {
108108
return this.dsMap.length
109109
}
110110

111-
getClassName() {
111+
getClassName () {
112112
return this.className
113113
}
114114
}
@@ -118,7 +118,7 @@ const SharedMemoryMixin = superclass =>
118118
* @param {string} name i.e. modelName
119119
* @returns {SharedMap}
120120
*/
121-
function findSharedMap(name) {
121+
function findSharedMap (name) {
122122
if (name === workerData.poolName) return workerData.sharedMap
123123

124124
if (workerData.dsRelated?.length > 0) {
@@ -127,14 +127,14 @@ function findSharedMap(name) {
127127
}
128128
}
129129

130-
function rehydrateSharedMap(name) {
130+
function rehydrateSharedMap (name) {
131131
const sharedMap = findSharedMap(name)
132132
if (sharedMap) return Object.setPrototypeOf(sharedMap, SharedMap.prototype)
133133
}
134134

135-
function createSharedMap(mapsize, keysize, objsize, name) {
135+
function createSharedMap (mapsize, keysize, objsize, name) {
136136
return Object.assign(new SharedMap(mapsize, keysize, objsize), {
137-
modelName: name, // assign modelName
137+
modelName: name // assign modelName
138138
})
139139
}
140140

@@ -146,16 +146,16 @@ function createSharedMap(mapsize, keysize, objsize, name) {
146146
* @param {import('./datasource-factory').dsOpts} options
147147
* @returns {import('./datasource').default}
148148
*/
149-
export function withSharedMemory(
149+
export function withSharedMemory (
150150
createDataSource,
151151
factory,
152152
name,
153153
namespace,
154154
options = {}
155155
) {
156-
const mapsize = options.mapsize || MAPSIZE
157-
const keysize = options.keysize || KEYSIZE
158-
const objsize = options.objsize || OBJSIZE
156+
const mapsize = options.mapsize || process.env.MAPSIZE || MAPSIZE
157+
const keysize = options.keysize || process.env.KEYSIZE || KEYSIZE
158+
const objsize = options.objsize || process.env.OBJSIZE || OBJSIZE
159159

160160
try {
161161
// use thread-safe shared map
@@ -169,7 +169,7 @@ export function withSharedMemory(
169169
dsMap: sharedMap,
170170
mixins: [DsClass => class extends SharedMemoryMixin(DsClass) {}].concat(
171171
options.mixins || []
172-
),
172+
)
173173
})
174174
}
175175

start.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
cd ../aegis-app
22
nohup node repo.js &
33
nohup node repo.js 8001 cache &
4-
cp ../aegis/wasm/build/release.wasm ../aegis-app/dist/main.wasm
5-
cd ../aegis
4+
cd ../aegis/wasm
5+
yarn build
6+
cd ../aegis/wasm
7+
yarn build
8+
yarn deploy
9+
cd ..
610
yarn link
711
cd ../aegis-host
812
yarn link @module-federation/aegis

wasm/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"asbuild:debug": "asc assembly/index.ts --exportRuntime --bindings --target debug",
1818
"asbuild:release": "asc assembly/index.ts --exportRuntime --bindings --target release",
1919
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
20+
"build": "npm run asbuild",
2021
"deploy": "cp build/release.wasm ../../aegis-app/dist/main.wasm",
2122
"test": "node tests",
2223
"start": "npx serve ."

0 commit comments

Comments
 (0)