refactor(go): Introduce Command interface to improve Go client request handling#2737
Conversation
9229f45 to
f9fbb90
Compare
|
@ex172000 regarding the request for tests and the common struct: I actually hesitated on this because the current foreign/go/contract directory is already quite cluttered, with types for various purposes mixed together. To avoid suffering in the cluttered types, I believe we should reorganize the directory structure in foreign/go to better categorize these types. However, if I include that reorganization and the new tests in this PR, the "lines changed" will explode, making this a >3000 lines of change(or even more, I don't know). My proposal:
I think it would make the review process easier. What do you think? |
|
@chengxilo sgtm! Yeah 3000+ LoC is definitely too large to review! It's just the byte operations are easy to go wrong in the future edits thus testing could be helpful! |
|
Hey @ex172000, I added that common struct |
Thanks for the update! Just wondering, some of the fields are still having JSON annotation, but new ones don't. Do we need it or we can drop it completely? |
Thank you for mentioning that. The JSON annotations seem to be autogenerated code from previous maintainer. They actually do nothing since HTTP is not implemented yet. I don't think we will implement the HTTP in go within a short term of time. Since currently they are useless and may not align with the JSON we actually need in HTTP SDK, maybe I can remove them all in another PR.🤔 |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need a review, please ensure CI is green and the PR is rebased on the latest master. Don't hesitate to ping the maintainers - either @core on Discord or by mentioning them directly here on the PR. Thank you for your contribution! |
Thanks. It's ok, I have to solve the conflicts first anyway.🤣 |
…ge, move test to contract package
bb6d83a to
259281b
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2737 +/- ##
============================================
- Coverage 67.70% 67.41% -0.29%
+ Complexity 739 708 -31
============================================
Files 1031 1044 +13
Lines 83912 83336 -576
Branches 60705 60004 -701
============================================
- Hits 56810 56183 -627
- Misses 24753 24804 +51
Partials 2349 2349
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@ex172000 @chengxilo what's the state of this PR? do you believe that it's acceptable quality for merge? |
I believe it's acceptable for now. |
I think the overall structure for this PR is good and @chengxilo has addressed many of the feedback. We anyway need more follow up PRs to further the refactoring/testing. |
Which issue does this PR close?
Closes # N/A
Rationale
Currently, the Go client performs web requests by calling:
While this works, it tightly couples request serialization and command code handling at the call site, making the API less expressive and harder to extend.
What changed?
Previously, each web request manually passed serialized bytes together with a
CommandCodeintosendAndFetchResponse, requiring callers to manage both serialization and command metadata.Now, we use:
Request types implement a new
Commandinterface that:MarshalBinarymethod)Code()method to return the associated command codeThis moves command metadata and serialization logic into the request type itself, improving encapsulation, readability, and extensibility.
Commandinterface anddofunction are already implemented in previous commitLocal Execution
AI Usage