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

libs/pubsub/query: specify peg version in go.mod #9099

Merged
merged 3 commits into from
Jul 27, 2022
Merged

Conversation

mark-rushakoff
Copy link
Contributor

The code to generate the pubsub queries was dependent on an unspecified
version of the peg tool. This brings peg into go.mod so it is on a fixed
version. This should also enable dependabot to notify us of future
updates to peg.

The version of query.peg.go generated from the current version of peg
correctly contains the special "Code generated by..." line to indicate
to other tools that the file is automatically generated and should
therefore be excluded from linters, etc.

I removed the make target as there were no git grep results referencing
"gen_query_parser"; directly running "go generate" is a reasonable
expectation in Go projects.

Now that "go run" is module aware, I would typically use "go run" inside
the go:generate directive, but in this case we go build to a gitignore-d
directory in order to work around the nondeterministic output detailed
in pointlander/peg#129.

The code to generate the pubsub queries was dependent on an unspecified
version of the peg tool. This brings peg into go.mod so it is on a fixed
version. This should also enable dependabot to notify us of future
updates to peg.

The version of query.peg.go generated from the current version of peg
correctly contains the special "Code generated by..." line to indicate
to other tools that the file is automatically generated and should
therefore be excluded from linters, etc.

I removed the make target as there were no git grep results referencing
"gen_query_parser"; directly running "go generate" is a reasonable
expectation in Go projects.

Now that "go run" is module aware, I would typically use "go run" inside
the go:generate directive, but in this case we go build to a gitignore-d
directory in order to work around the nondeterministic output detailed
in pointlander/peg#129.
The newly generated peg code returns an error from Init(); the previous
version was niladic.
@creachadair
Copy link

Alternatively you might want to consider #7338

@tychoish
Copy link
Contributor

I think #7383 is the better solution to this problem, but also this change is fine.

My only concern is that we make sure that the regeneration detector triggers for this would detect if there's an upgrade to the library that causes the code to change. I sometimes see errors caused by the generated code change detector, but haven't had cause to dig into its actual operation.

@creachadair
Copy link

To be clear, I don't have any objection to this change either. It's just that we don't need to depend on code generation and we get a massive speedup and reduction in memory use with the other approach. (That said, it's the same API either way)

@mark-rushakoff
Copy link
Contributor Author

I'm okay with the principle of bringing in the alternative implementation #7338 instead of this -- I'm inclined to say it's "safe" for 0.37, but I don't have enough context to say so confidently. I don't mind dropping this PR and porting #7338 instead, so WDYT @tychoish @creachadair?

@creachadair
Copy link

I'm okay with the principle of bringing in the alternative implementation #7338 instead of this -- I'm inclined to say it's "safe" for 0.37, but I don't have enough context to say so confidently. I don't mind dropping this PR and porting #7338 instead, so WDYT @tychoish @creachadair?

It's probably simpler to just merge this as-is for now. One thing I forgot is that because main is based on v0.34.x, we'd have to re-address the event structure change. That makes a port more work than it would have been.

@mark-rushakoff mark-rushakoff added the S:automerge Automatically merge PR when requirements pass label Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:automerge Automatically merge PR when requirements pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants