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

Remove dependency on the js/ package (and goja) from lib/* packages #2809

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

na--
Copy link
Member

@na-- na-- commented Dec 7, 2022

This doesn't depend on anything else, it should be safe to merge as is.

This should close #2535, I think 🤔 Between it and #2536, go.k6.io/lib and its sub-packages shouldn't depend on go.k6.io/js or github.com/dop251/goja, right?

go list -f '{{ join .Imports "\n" }}' ./... | sort -u | grep -E 'goja|go.k6.io/k6/js' returns no results in the lib/ package, at least 🤞

Unfortunately, I couldn't make depbuard work correctly, and I have no time to debug that further, so I'll leave that to someone else if they want to. From what I understand by skimming https://golangci-lint.run/usage/linters/#depguard, adding something like this in the linters-settings: section of .golangci.yml should have worked, but it didn't:

  depguard:
    list-type: denylist
    packages:
      - github.com/dop251/goja
      - go.k6.io/k6/js
      - go.k6.io/k6/js/**
    ignore-file-rules:
      - "js/**/*.go"
      - "cmd/*.go"

The goal is to ensure we don't import goja or the js package anywhere except js/ and cmd/, and maybe we can even restrict that further 🤔 If someone can make the linter work, that is 😅

@na-- na-- added this to the v0.43.0 milestone Dec 7, 2022
@na-- na-- requested review from mstoykov, oleiade and codebien December 7, 2022 12:11
@na-- na-- changed the title Remove dependency on the js/ package (and goja) from lib/* packages Remove dependency on the js/ package (and goja) from lib/* packages Dec 7, 2022
@na-- na-- requested review from imiric and codebien and removed request for codebien December 7, 2022 12:16
@@ -174,7 +174,7 @@ func (c *Conn) Close() error {
}

type statsHandler struct {
vu modules.VU
getState func() *lib.State
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Do we need this to be a function 🤔

I guess for future proofing in case we start chaning what lib.State is returned. But IIRC we basically return the same struct eitherway.

We do need it to be a function on the VU as it is an interface. But I wonder if we can skip the inderection here 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd slightly prefer to keep the function, just so we keep the same sort of API structure and in case it might matter in the future, but I can make the change if others feel the same as you.

FWIW, I even considered adding another interface with just a State() *lib.State function in grpext/ and continuing to pass the VU directly, or even moving the whole DefaultOptions function back in the js/ package. The current approach seemed like a nice middle ground 😅

@na-- na-- added the refactor label Dec 7, 2022
Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

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

👍🏻

@na-- na-- requested a review from mstoykov December 12, 2022 11:13
@na-- na-- linked an issue Dec 12, 2022 that may be closed by this pull request
@na-- na-- merged commit dbdcfc5 into master-next Dec 13, 2022
@na-- na-- deleted the remove-js-dep-from-lib branch December 13, 2022 14:46
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.

Make certain ./lib doesn't require goja
3 participants