-
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
js/grpc: modules.Module migration #2365
Conversation
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 🎉 . I did leave some non essential nit picks
8e31bc2
to
83aa13a
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.
Thanks! The PR looks good, I left a few suggestions that can improve the readability.
js/modules/k6/grpc/client.go
Outdated
func (c *Client) Connect(ctxPtr *context.Context, addr string, params map[string]interface{}) (bool, error) { | ||
state := lib.GetState(*ctxPtr) | ||
func (c *Client) Connect(addr string, params map[string]interface{}) (bool, error) { | ||
state := c.vu.State() |
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 noticed that there are several places (here and other parts of there code) where we use this check:
state := c.vu.State()
if state == nil {
return false, errConnectInInitContext
}
How about adding a simple method like modules.IsInitialContext(vu VU) bool
I believe that improves the readability of the code, and what is also essential make code more maintainable since we consolidate the logic that identifies that the particular place is dependent during what phase it is executing?
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 like the idea in terms of readability, but in this way, we can't reuse the state
variable so for most of the methods we are doing 2x on the call for resolving the State
that comes from the slow context.
Lines 169 to 171 in 0dda328
func (m *moduleVUImpl) State() *lib.State { | |
return lib.GetState(*m.ctxPtr) // TODO thread it correctly instead | |
} |
so I'm feeling a bit conflicted here without having some profiling data
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.
@olegbespalov please make a separate issue about this.
@codebien in #2228 I in practice stop getting the state from a context, which is a thing that needs to happen for everything at some point either way.
But I do think this should be made ina separate PR and probably across the codebase, so please open an issue @olegbespalov so we can discuss the API for example and whether we want to do this for more stuff
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.
Just to keep the connection, opened an issue #2368
I did some refactor inspired by your suggestions. WDYT? |
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.
PR looks good to me, great work! 👍
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.
Hm I think we can't remove the goroutine because of #1623 (comment) also ... I really prefer to not change the code all that much in the same PR that already changes a lot of stuff.
If there are some refactoring ideas, please move them to a separate PR, so we can have smaller and easier to review PRs instead of just doing a lot of those in one 🙏
@mstoykov We should be able to remove it as documented in the commit's description c93b8b0 From my understanding, we did it in that way just for getting the TLS error that is covered by I can move in another PR the stats handler refactor and the reorder. WDYT? |
f7c0a8f
to
236bd56
Compare
This was added in grpc/grpc-go#3430 which was released before the PR that added grpc to k6(and before the comment I linked to). I have no idea if this was just missed or is buggy and just doens't cover all cases 🤷 . I guess if @rogchap might have some idea, as well as @na--. I have found only one issue grpc/grpc-go#4822, which seems not relevant, but there are others where it seems like TLS errors still seem to not work in some cases. Unfortunately I don't really understand enough to know if those matter or not for our case :(. Your test for example seems to handle what the issue is talking about so 🤷 . If we can go back to the previous code and have this in a separate PR I think it will be better. We also (AFAIK) don't have that many gRPC users so an introduced bug here will likely stay there for while before we can fix it. So if it isn't that much work I prefer if this gets split , sorry :( p.s. thansk for the commit message, and sorry for skip reading it, but unfortunately I am not particularly certain this catches all the cases the previous one did :( |
ba43716
to
61886b9
Compare
@mstoykov @olegbespalov I restored the codebase without the Connect/dial split. I let only the change for the dedicated method for the parameters' parse. |
Implemented the latest API for JS modules.
61886b9
to
adbd6ef
Compare
seems to be because of the test |
f4dbdec
to
5bf2c07
Compare
Migrated
k6/grpc
to themodules.Module
(akamodules.ModuleV2
) interface.