Commit 6723a3ab125343529593a107313cd31c8eb38d7a
save container type
wanderer committed on 7/26/2017, 5:52:43 PMParent: 1e3ac999b894c127c15636b20fa61d8a5e60dd0f
Files changed
index.js | changed |
kernel.js | changed |
package.json | changed |
tests/index.js | changed |
index.js | ||
---|---|---|
@@ -147,8 +147,9 @@ | ||
147 | 147 | * @param {Class} Constructor - a Class for instantiating the container |
148 | 148 | * @param {*} args - any args that the contructor takes |
149 | 149 | */ |
150 | 150 | registerContainer (type, Constructor, args) { |
151 | + Constructor.type = type | |
151 | 152 | this._containerTypes[type] = { |
152 | 153 | Constructor: Constructor, |
153 | 154 | args: args |
154 | 155 | } |
kernel.js | ||
---|---|---|
@@ -90,9 +90,9 @@ | ||
90 | 90 | |
91 | 91 | this.ports.addReceivedPorts(message) |
92 | 92 | let result |
93 | 93 | try { |
94 | - result = await this.container[method](message) || {} | |
94 | + result = await this.container[method](message) | |
95 | 95 | } catch (e) { |
96 | 96 | result = { |
97 | 97 | exception: true, |
98 | 98 | exceptionError: e |
package.json | ||
---|---|---|
@@ -43,9 +43,9 @@ | ||
43 | 43 | "istanbul": "^1.1.0-alpha.1", |
44 | 44 | "level-promise": "^2.1.1", |
45 | 45 | "levelup": "^1.3.8", |
46 | 46 | "memdown": "^1.2.4", |
47 | - "primea-wasm-container": "0.0.0", | |
47 | + "primea-abstract-container": "0.0.2", | |
48 | 48 | "standard": "10.0.2", |
49 | 49 | "tape": "^4.5.1" |
50 | 50 | } |
51 | 51 | } |
tests/index.js | ||
---|---|---|
@@ -1,29 +1,22 @@ | ||
1 | 1 | const tape = require('tape') |
2 | 2 | const IPFS = require('ipfs') |
3 | +const AbstractContainer = require('primea-abstract-container') | |
3 | 4 | const Hypervisor = require('../') |
4 | 5 | |
5 | 6 | // start ipfs |
6 | 7 | const node = new IPFS({ |
7 | 8 | start: false |
8 | 9 | }) |
9 | 10 | |
10 | -class BaseContainer { | |
11 | - constructor (kernel) { | |
12 | - this.kernel = kernel | |
13 | - } | |
14 | - | |
11 | +class BaseContainer extends AbstractContainer { | |
15 | 12 | initialize (message) { |
16 | 13 | this.kernel.state.code = message.data.byteLength ? message.data : undefined |
17 | 14 | const port = message.ports[0] |
18 | 15 | if (port) { |
19 | 16 | this.kernel.ports.bind('root', port) |
20 | 17 | } |
21 | 18 | } |
22 | - | |
23 | - onIdle () { | |
24 | - this.kernel.shutdown() | |
25 | - } | |
26 | 19 | } |
27 | 20 | |
28 | 21 | node.on('ready', () => { |
29 | 22 | tape('basic', async t => { |
Built with git-ssb-web