8000 feat: optimize refresh method by hwbrzzl Β· Pull Request #956 Β· goravel/framework Β· GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: optimize refresh method #956

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

Merged
merged 5 commits into from
Mar 16, 2025
Merged

feat: optimize refresh method #956

merged 5 commits into from
Mar 16, 2025

Conversation

hwbrzzl
Copy link
Contributor
@hwbrzzl hwbrzzl commented Mar 15, 2025

πŸ“‘ Description

We need to refresh all modules when testing in goravel/example with different drivers.

βœ… Checks

  • Added test cases for my code

@Copilot Copilot AI review requested due to automatic review settings March 15, 2025 15:41
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 15, 2025 15:41
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the refresh method to support refreshing specific instances or all refreshable modules (except the config binding) when needed. Key changes include updating the Refresh method signatures in the container, mocks, and contracts, adjusting test cases for the new behavior, and a minor behavioral change in the HTTP throttle middleware.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
foundation/container_test.go Updated tests to verify loading of bindings using the new key "ok"
foundation/container.go Modified Refresh method to accept variadic parameters and skip config
mocks/foundation/Application.go Adjusted mock signatures and variadic argument handling for Refresh
contracts/foundation/application.go Updated Refresh interface to match new signature
database/orm/orm.go Updated refresh function signature for consistency
http/middleware/throttle.go Changed loop break to early return in throttle middleware logic
Comments suppressed due to low confidence (2)

foundation/container.go:324

  • [nitpick] The use of the parameter name 'bindings' here might be confusing as it is used to specify keys for instance deletion. Consider renaming it to 'keys' or 'refreshKeys' for improved clarity.
func (c *Container) Refresh(bindings ...any) {

mocks/foundation/Application.go:2143

  • [nitpick] Consider simplifying the conversion of 'args' into a []interface{} (if supported by the mock library) to make the code more concise and readable.
for i, a := range args[0:] {

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: cc927ef Previous: ab139f2 Ratio
Benchmark_EncryptString 6951 ns/op 2160 B/op 15 allocs/op 2299 ns/op 2160 B/op 15 allocs/op 3.02
Benchmark_EncryptString - ns/op 6951 ns/op 2299 ns/op 3.02
Benchmark_DecryptString 6674 ns/op 2040 B/op 17 allocs/op 2100 ns/op 2040 B/op 17 allocs/op 3.18
Benchmark_DecryptString - ns/op 6674 ns/op 2100 ns/op 3.18

This comment was automatically generated by workflow using github-action-benchmark.

// configInstance, ok := c.instances.Load(contracts.BindingConfig)

c.instances.Range(func(key, value any) bool {
if key != contracts.BindingConfig {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't delete the base service provider.

Copy link
codecov bot commented Mar 15, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Please upload report for BASE (v1.15.x@9f0f6a6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
database/orm/orm.go 0.00% 1 Missing ⚠️
http/middleware/throttle.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x     #956   +/-   ##
==========================================
  Coverage           ?   68.61%           
==========================================
  Files              ?      219           
  Lines              ?    18967           
  Branches           ?        0           
==========================================
  Hits               ?    13015           
  Misses             ?     5285           
  Partials           ?      667           

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl merged commit 03bfb25 into v1.15.x Mar 16, 2025
13 of 16 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-refresh branch March 16, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0