-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: add UnregisterModule function #23127
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes involve updates to the Changes
Sequence DiagramsequenceDiagram
participant User
participant ModuleRegistry
participant UnregisterModule
participant modouleProtoType
User->>UnregisterModule: Call with config
UnregisterModule->>modouleProtoType: Check module type
modouleProtoType-->>UnregisterModule: Return proto.Message, reflect.Type
UnregisterModule->>ModuleRegistry: Remove module
The sequence diagram illustrates the process of unregistering a module, showing the interaction between the user, the Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
This comment has been minimized.
This comment has been minimized.
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
depinject/appconfig/module.go (2)
14-21
: Possible Typo in Function Name.
The function namemodouleProtoType
appears to have a misspelling. Consider renaming it tomoduleProtoType
for clarity and consistency.
14-21
: Use of Panic.
Currently, the code panics if the module isn't aproto.Message
. For production-level robustness, consider handling the error gracefully and returning a descriptive error instead.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
depinject/CHANGELOG.md
(1 hunks)depinject/appconfig/module.go
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
depinject/appconfig/module.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
depinject/CHANGELOG.md (1)
Pattern **/*.md
: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"
🔇 Additional comments (1)
depinject/CHANGELOG.md (1)
25-26
: Changelog Entry Verified.
The new entry referencing PR [#23127] properly documents the addition of UnregisterModule
.
// UnregisterModule from the global module registry. Can be used to overwrite previously | ||
// registered module. | ||
func UnregisterModule(config any, options ...Option) { | ||
_, ty := modouleProtoType(config) | ||
delete(internal.ModuleRegistry, ty) | ||
} | ||
|
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.
Potential Race Condition in Global Registry.
delete(internal.ModuleRegistry, ty)
is performed on a global map. Without synchronization, if multiple goroutines register or unregister modules concurrently, data races can occur. Consider adding a mutex around ModuleRegistry
operations to ensure thread safety.
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.
design looks good, do you have a module i can test with?
Description
Closes: #XXXX
In order to overwrite a default genesis from the SDK module we have to wrap the
AppModule
. Since the SDK modules are automatically supplied ot depinject in theinit
function, we need to unregister them, before registering the wrapped AppModule.Use case: the default bank
DenomMetadata
is empty. I want to predefine denoms into it.The flow is:
UnergisterModule
function -- this PRAuthor Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
UnregisterModule
function to allow removing previously registered modules from the global module registryDocumentation
Note: This release continues to evolve the
depinject
module with improved module management capabilities.