-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 context-based utils #2384
Conversation
lib/context.go
Outdated
state.Logger.Warn("GetState has been deprecated and it could be removed in the next versions." + | ||
"Please, consider to replace it using the new modules.VU API.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a sync.Once
for each method for avoiding printing the warning multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea 🤔
js/common/context.go
Outdated
func GetInitEnv(ctx context.Context) *InitEnvironment { | ||
logger := logger(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check and skip in case of logger == nil
? It would be a bug but maybe avoid us to hotfix it
3e9c0b8
to
ec7357c
Compare
I removed all the logs stuff and just added what suggested by #2384 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure that the log warning will be printed per each VU(but haven't tested). It's probably good idea if it's only once though ;).
Although on the other hand,it will probably drive the point home that this requires changes if it fills the screen 🤣
js/initcontext.go
Outdated
i.logger.Warnf(`Module '%s' is using deprecated APIs that will be removed in k6 v0.38.0,`+ | ||
` for more details on how to update it see`+ | ||
` https://k6.io/docs/extensions/guides/create-an-extension/#advanced-javascript-extension`, name) | ||
|
||
return i.moduleVUImpl.runtime.ToValue(common.Bind(i.moduleVUImpl.runtime, mod, i.moduleVUImpl.ctxPtr)), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure this will be logged for each VU
js/initcontext.go
Outdated
mod = perInstance.NewModuleInstancePerVU() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should drop this lines and the modules.HasModuleInstancePerVU
interface 🤔
ec7357c
to
d1861e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will print only once even if multiple modules don't use the new API. But I see this as corner case that isn't worth the complexity ;)
The new modules API made this API not required anymore. Both internal and external modules can now use the same unique way for accessing the VU State.
d1861e0
to
c9958ec
Compare
Yep, it was my motivation for printing on every call to require. But based on your previous comment I changed my opinion, the user can always fix run by run and it maintains the code simpler without adding and injecting dependencies, in the end, it will be there for only one release. |
I haven't tested it with an extension though, just read the code |
Deprecating the context-based utils functions. They are anticipating the next step where we could remove all of them from the
k6
public API.Closes #2344