Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small js refactor #2373

Merged
merged 7 commits into from
Feb 4, 2022
Merged

Small js refactor #2373

merged 7 commits into from
Feb 4, 2022

Conversation

mstoykov
Copy link
Collaborator

@mstoykov mstoykov commented Feb 4, 2022

Please review commit by commit.

The idea(s) of this PR are to move away from common.Bind usage and to facilitate some changes I need for #2228 without making that PR huge

@mstoykov mstoykov added this to the v0.37.0 milestone Feb 4, 2022
There really isn't a reason why it should use the context - if the
context is done the whole runtime is interrupted so it won't even get to
that code
Copy link
Collaborator

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 😍

Few comments

ctxPtr := new(context.Context)

func (b *Bundle) Instantiate(
logger logrus.FieldLogger, vuID uint64, vuImpl *moduleVUImpl,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger logrus.FieldLogger, vuID uint64, vuImpl *moduleVUImpl,
logger logrus.FieldLogger, vuID uint64, vuImpl *moduleVUImpl,

Could now we have vuID as part of vuImpl?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably in another PR see #2373 (comment)

Comment on lines 258 to +260
// Instantiate the bundle into a new VM using a bound init context. This uses a context with a
// runtime, but no state, to allow module-provided types to function within the init context.
rt := goja.New()
init := newBoundInitContext(b.BaseInitContext, ctxPtr, rt)
if err := b.instantiate(logger, rt, init, vuID); err != nil {
vuImpl.runtime = goja.New()
Copy link
Collaborator

@codebien codebien Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we now directly inject a vuImpl with an initialized runtime so we can maintain the initialization in one central place? (e.g. runner.newVU)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a followign PR :P There are in practice a lot more changes, I just really needed moduleVUImpl to be part of VU and everything else was gravy

@mstoykov mstoykov merged commit 9c58b15 into master Feb 4, 2022
@mstoykov mstoykov deleted the smallJSRefactor branch February 4, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants