-
Notifications
You must be signed in to change notification settings - Fork 48
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
crit: fix proto imports for library #109
crit: fix proto imports for library #109
Conversation
Couple of ideas which would be nice to have. Can you introduce a markdown lint runt like https://github.com/checkpoint-restore/checkpointctl/blob/main/.github/workflows/markdown-lint.yml This would probably also mean to change the existing top-level With the introduction of Python code if would be nice to run the Python code also through a linter like |
Got it. I've opened a PR for the markdown linter, I'll add a Python linter along with the script in this PR. |
d876b9f
to
efa03cd
Compare
e68f577
to
b826831
Compare
b826831
to
e67bead
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #109 +/- ##
==========================================
- Coverage 48.84% 48.33% -0.51%
==========================================
Files 22 23 +1
Lines 2381 2435 +54
==========================================
+ Hits 1163 1177 +14
- Misses 1059 1084 +25
- Partials 159 174 +15
☔ View full report in Codecov by Sentry. |
e67bead
to
7e3a0d0
Compare
a2f943a
to
10943fa
Compare
0b053c6
to
3697421
Compare
Upon importing the library locally with a simple Go file that looks like below: package main
import ...
func main() {
critter := crit.New(...)
fmt.Println(critter)
} I noted the following numbers:
|
06d2aa5
to
20d7cdd
Compare
c7e0870
to
c0cfc38
Compare
This PR get really big. Can you move the the last three commits to a separate commit. That looks like something we can merge easily and then you can rebase upon that. |
Since the proto-gen script will also be placed in the scripts directory, it is ideal to have each script in its own subdirectory along with the associated tests and Makefile. Signed-off-by: Prajwal S N <[email protected]>
Previously, CRIT was using an overengineered Makefile stunt to generate protobuf bindings for the CLI. The problem of statically linking all the bindings while using the library as a dependency cannot be resolved in a reasonable manner in the Makefile. The logic has been moved out into a Python script. Signed-off-by: Prajwal S N <[email protected]>
Using the new Python script, the protobuf bindings are now generated in independent packages. This commit refactors CRIT to work with the new organisation of files. It does not change the implementation of CRIT in any way apart from resolving the imports correctly. Signed-off-by: Prajwal S N <[email protected]>
The proto struct required for encoding or decoding the images was previously being inferred from the `images.ProtoHandler()` function. Now, it is inferred using that only in the CLI, and is passed to the actual CRIT functions as a parameter. This eliminates the redundant protobuf bindings being imported when using CRIT as a library. Signed-off-by: Prajwal S N <[email protected]>
Since we have improved error handling substantially in this PR, the coverage has gone down slightly (we cannot test the failure cases like failing to open file, failing to write to file, etc.) |
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
@snprajwal Can you post the binary size of phaul (in test) before and after this PR? A hello world in go needs 1.8MB on my system and the phaul binary needs 7.7MB. What size do you see of the phaul test binary after your changes? |
@adrianreber The phaul binary currently sits at 7.2M on my system |
The following results show the size of the Build from
Build from
|
Thanks. So this change brings small improvements. Good. |
When using CRIT as a library, all proto bindings are imported and statically linked. This PR aims to fix this by moving each proto binding into its own package and importing all of them only for the CLI to use. The library will be refactored to allow the user to pass the struct instead of deducing it using
handler.go
Tasks:
handler.go