-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Deprecate old JS Module "API" #2949
Comments
Repeating my point from Slack: while this would simplify some of our maintenance and docs, I don't see why we should force developers of basic extensions to upgrade to the much more complex Like @mstoykov mentioned, 44 out of 73 extensions currently don't use There are many such extensions, like xk6-file, xk6-csv and Mihail's xk6-counter. All of these build and work with k6 v0.43.1 as is, and will likely countinue to build and work without having to upgrade. Sure, you may consider them "toys", but they're probably very useful to some users. By deprecating this API we're essentially breaking all of these extensions, and since they now need to actually depend on a larger API that may not be stable, we're forcing them to have to update more frequently, which as we've seen, just isn't likely to happen. I'm not strongly against this, mind you, just see more reasons against it than for, but I'm curious what everyone else thinks. |
I disagree with the point that the new API is "much more complex" or harder to grok than the old "API". The old one was basically "yeehaw, somehow your Go code is usable in JS, but don't ask me how or how it maps to a VU, YOLO!" 🤣 The new API actually has an... API... 😅 And the boilerplate, if you don't need the new capabilities, is only something like 10-15 lines on top. This is a minimal example if you don't care about any of the new APIs or doing anything complicated with your module: func init() {
modules.Register("k6/x/compare", &RootModule{})
}
type RootModule struct{}
func (*RootModule) NewModuleInstance(_ modules.VU) modules.Instance {
return &ModuleInstance{}
}
type ModuleInstance struct {}
func (mi *ModuleInstance) Exports() modules.Exports {
return modules.Exports{
Default: yourOldLogic,
}
} Considering the That said, I am not against a longer grace period though. We can wrap the old ad-hoc extensions in some pseudo- |
Some data, and the way it was "generated": I did have repos checked out locally from a year+ ago so the previous results were a bit ... wrong :(, sorry. I basically have a script that checkouts all the repos as in: for i in `curl 'https://raw.githubusercontent.com/grafana/k6-docs/master/src/data/doc-extensions/extensions.json' | jq -r '.extensions | .[] | .url'` ; do git clone ${i} || echo $i >> broken.txt; done Which gets the data about extensions from the "registry" This script checkouts 69 repos at this point and there are no repos that are "broken" at this point in time. Then I run for i in xk6* ; do cd $i; echo -n "$(git remote -v) " ; rg ModuleInstance . | wc -l ;cd - ; done | grep '(push)' Which will (badly) print the URL of the repo + how many times Then if you grep for for i in xk6* ; do cd $i; echo -n "$(git remote -v)" ; rg ModuleInstance . | wc -l ;cd - ; done | grep '(push)' | grep "\b0\b" | wc -l you get 46 - so that many extension do not have
you get 37 and 10 of those are by szkiba whose most extensions just won't compile or even if they do they do use the old So we are left with 27 $ for i in xk6* ; do cd $i; echo -n "$(git remote -v)" ; rg ModuleInstance . | wc -l ;cd - ; done | grep push | grep "\b0\b" | grep -v output | grep -v szkiba
origin https://github.com/grafana/xk6-amqp (push)0
origin https://github.com/xvzf/xk6-avro (push)0
origin https://github.com/tmieulet/xk6-cognito (push)0
origin https://github.com/thotasrinath/xk6-couchbase (push)0
origin https://github.com/dgzlopes/xk6-datadog (push)0
origin https://github.com/grafana/xk6-docker (push)0
origin https://github.com/BarthV/xk6-es (push)0
origin https://github.com/avitalique/xk6-file (push)0
origin https://github.com/skibum55/xk6-git (push)0
origin https://github.com/AckeeCZ/xk6-google-iap (push)0
origin https://github.com/heww/xk6-harbor (push)0
origin https://github.com/gpiechnik2/xk6-httpagg (push)0
origin https://github.com/dgzlopes/xk6-interpret (push)0
origin https://github.com/dgzlopes/xk6-kv (push)0
origin https://github.com/gjergjsheldija/xk6-mllp (push)0
origin https://github.com/GhMartingit/xk6-mongo (push)0
origin https://github.com/patrick-janeiro/xk6-neo4j (push)0
origin https://github.com/wosp-io/xk6-playwright (push)0
origin https://github.com/Juandavi1/xk6-prompt (push)0
origin https://github.com/olvod/xk6-pubsub (push)0
origin https://github.com/gpiechnik2/xk6-smtp (push)0
origin https://github.com/mridehalgh/xk6-sqs (push)0
origin https://github.com/grafana/xk6-ssh (push)0
origin https://github.com/NAlexandrov/xk6-tcp (push)0
origin https://github.com/maksimall89/xk6-telegram (push)0
origin https://github.com/dgzlopes/xk6-url (push)0
origin https://github.com/vvarp/xk6-wamp (push)0 A different script #!/bin/sh
for i in `curl 'https://raw.githubusercontent.com/grafana/k6-docs/master/src/data/doc-extensions/extensions.json' | jq -r '.extensions | .[] | .url'` ; do xk6 build master --with ${i##https:\/\/} || echo $i >> broken.txt; done Will gives us what extensions do not build with the current master and the list is 17 long:
This is only about compilation so:
edit: I have now published some code around this as a repo that ... I might or might not try to maintain |
After an internal discussion, we decided to clean a milestone since the issue was jumping between milestones without completion. Once we determine which milestone it lands, we set the right one. |
I think we should deprecate JS extensions (i.e. extensions to the JS API written in Go 😅) that don't implement the JS
Module
interface:k6/js/modules/modules.go
Lines 27 to 32 in 1993ac1
JS Modules that don't implement this API are basically an
interface{}
that is directly given to goja to deal with. For some historical context:At this point, unless we have a specific reason to support these
interface{}
JS modules I don't know about, I think it's fine to officially and fully deprecate them, right?My proposal is that:
map[string]interface{}
tomap[string]modules.Module
) and start emitting a warning if such an xk6 extension module is used that doesn't implement it.interface{}
modules, the js/modules.Register() method will start requiringa modules.Module
as an argument and any old JS extensions will need to be rewritten.The text was updated successfully, but these errors were encountered: