Skip to content

Commit

Permalink
save container type
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed Jul 26, 2017
1 parent 1e3ac99 commit 6723a3a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ module.exports = class Hypervisor {
* @param {*} args - any args that the contructor takes
*/
registerContainer (type, Constructor, args) {
Constructor.type = type
this._containerTypes[type] = {
Constructor: Constructor,
args: args
Expand Down
2 changes: 1 addition & 1 deletion kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = class Kernel {
this.ports.addReceivedPorts(message)
let result
try {
result = await this.container[method](message) || {}
result = await this.container[method](message)
} catch (e) {
result = {
exception: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"level-promise": "^2.1.1",
"levelup": "^1.3.8",
"memdown": "^1.2.4",
"primea-wasm-container": "0.0.0",
"primea-abstract-container": "0.0.2",
"standard": "10.0.2",
"tape": "^4.5.1"
}
Expand Down
11 changes: 2 additions & 9 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
const tape = require('tape')
const IPFS = require('ipfs')
const AbstractContainer = require('primea-abstract-container')
const Hypervisor = require('../')

// start ipfs
const node = new IPFS({
start: false
})

class BaseContainer {
constructor (kernel) {
this.kernel = kernel
}

class BaseContainer extends AbstractContainer {
initialize (message) {
this.kernel.state.code = message.data.byteLength ? message.data : undefined
const port = message.ports[0]
if (port) {
this.kernel.ports.bind('root', port)
}
}

onIdle () {
this.kernel.shutdown()
}
}

node.on('ready', () => {
Expand Down

0 comments on commit 6723a3a

Please sign in to comment.