Skip to content

Commit

Permalink
added raw node to kernel
Browse files Browse the repository at this point in the history
Signed-off-by: wanderer <mjbecze@gmail.com>
  • Loading branch information
wanderer committed Oct 22, 2017
1 parent 5abe675 commit e0c13d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions creationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ module.exports = class CreationService {
state.code = code
}

// save the container in the state
await this.hypervisor.tree.set(idHash, state)

// create the container instance
const instance = await this.hypervisor._loadInstance(idHash, state)
const instance = await this.hypervisor._loadInstance(idHash)

// send the intialization message
await instance.create(message)

// save the container in the state
await this.hypervisor.tree.set(idHash, state)

if (!Object.keys(instance.ports.ports).length) {
this.hypervisor.addNodeToCheck(instance.id)
}
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,16 @@ module.exports = class Hypervisor {
}

// loads an instance of a container from the state
async _loadInstance (id, state) {
if (!state) {
state = await this.tree.get(id, true).then(result => result.value)
}
const container = this._containerTypes[state.type]
async _loadInstance (id) {
const state = await this.tree.get(id, true)
const container = this._containerTypes[state.value.type]

// create a new kernel instance
const kernel = new Kernel({
hypervisor: this,
state: state,
code: state.code,
state: state.value,
node: state.node,
code: state.value.code,
container: container,
id: id
})
Expand Down Expand Up @@ -133,6 +132,7 @@ module.exports = class Hypervisor {
for (const id of unlinked) {
await this.tree.delete(id)
}

return this.tree.flush()
}

Expand Down
1 change: 1 addition & 0 deletions kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = class Kernel {
constructor (opts) {
this.state = opts.state
this.code = opts.code
this.node = opts.node
this.hypervisor = opts.hypervisor
this.id = opts.id
this.container = new opts.container.Constructor(this, opts.container.args)
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ tape('should remove subgraphs', async t => {

class Sub extends BaseContainer {
static get typeId () {
return 299
return 199
}
}

Expand Down

0 comments on commit e0c13d7

Please sign in to comment.