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

feat: Move bindings to config #865

Merged
merged 6 commits into from
Feb 9, 2025
Merged

Conversation

ahmed3mar
Copy link
Contributor

@ahmed3mar ahmed3mar commented Feb 7, 2025

📑 Description

Closes https://github.com/goravel/goravel/issues/?

Normal binding for internal packages will include the package even we never registered it in app because of Make func in container which make the output file larger, so we need a diff. way to bind these packages and keep Make functions in container

@coderabbitai summary

fresh goravl contains all service providers

➜  goravel git:(v1.15.x) ✗ go build -o goravel main.go    
➜  goravel git:(v1.15.x) ✗ ll
total 152304
-rw-r--r--@  1 ahmed3mar  staff   550B Feb  7 10:01 Dockerfile
-rw-r--r--@  1 ahmed3mar  staff   1.0K Feb  7 10:01 LICENSE
-rw-r--r--@  1 ahmed3mar  staff   9.2K Feb  7 10:01 README.md
-rw-r--r--@  1 ahmed3mar  staff   9.0K Feb  7 10:01 README_zh.md
drwxr-xr-x@  7 ahmed3mar  staff   224B Feb  7 10:01 app
drwxr-xr-x@  3 ahmed3mar  staff    96B Feb  7 10:01 bootstrap
drwxr-xr-x@ 16 ahmed3mar  staff   512B Feb  7 10:01 config
drwxr-xr-x@  5 ahmed3mar  staff   160B Feb  7 10:01 database
-rw-r--r--@  1 ahmed3mar  staff   114B Feb  7 10:01 docker-compose.yml
-rw-r--r--@  1 ahmed3mar  staff   9.9K Feb  8 02:57 go.mod
-rw-r--r--@  1 ahmed3mar  staff   111K Feb  8 02:57 go.sum
-rwxr-xr-x@  1 ahmed3mar  staff    74M Feb  8 12:35 goravel           # <--- 74MB
-rw-r--r--@  1 ahmed3mar  staff   707B Feb  7 10:01 main.go
drwxr-xr-x   5 ahmed3mar  staff   160B Feb  7 11:45 packages
drwxr-xr-x@  3 ahmed3mar  staff    96B Feb  7 10:01 public
drwxr-xr-x@  3 ahmed3mar  staff    96B Feb  7 10:01 resources
drwxr-xr-x@  5 ahmed3mar  staff   160B Feb  7 10:01 routes
drwxr-xr-x@  4 ahmed3mar  staff   128B Feb  7 10:01 storage
drwxr-xr-x@  4 ahmed3mar  staff   128B Feb  7 10:01 tests

with flags -s -w

go build -ldflags="-s -w" -o goravel main.go
-rwxr-xr-x@  1 ahmed3mar  staff    53M Feb  8 12:37 goravel           # <--- 53M

but if we need to use goravel for example only with log, console, http, route and gin only and our project doesn't need for database or queue system or others

normal

go build -ldflags="-s -w" -o goravel main.go
-rwxr-xr-x@  1 ahmed3mar  staff    39M Feb  8 12:40 goravel          # <--- 39M

with move binding to external not inside same package

go build -ldflags="-s -w" -o goravel main.go
-rwxr-xr-x@  1 ahmed3mar  staff    22M Feb  8 12:40 goravel         # <--- 22M

the size of output file is decreased from 39MB to 22MB

✅ Checks

  • Added test cases for my code

Copy link
Contributor

coderabbitai bot commented Feb 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 26.58228% with 58 lines in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
auth/service_provider.go 0.00% 6 Missing ⚠️
cache/service_provider.go 0.00% 5 Missing ⚠️
event/service_provider.go 0.00% 5 Missing ⚠️
mail/service_provider.go 0.00% 5 Missing ⚠️
foundation/container.go 83.33% 4 Missing ⚠️
filesystem/service_provider.go 0.00% 3 Missing ⚠️
grpc/service_provider.go 0.00% 3 Missing ⚠️
queue/service_provider.go 0.00% 3 Missing ⚠️
schedule/service_provider.go 0.00% 3 Missing ⚠️
session/service_provider.go 0.00% 3 Missing ⚠️
... and 12 more
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x     #865   +/-   ##
==========================================
  Coverage           ?   69.79%           
==========================================
  Files              ?      218           
  Lines              ?    18890           
  Branches           ?        0           
==========================================
  Hits               ?    13184           
  Misses             ?     4991           
  Partials           ?      715           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Feb 8, 2025

Thanks for your PR, could you add more descriptions or examples for this requirement? To explain what the goal of this PR is.

@ahmed3mar
Copy link
Contributor Author

@hwbrzzl added sample with, without PR updates

@ahmed3mar ahmed3mar marked this pull request as ready for review February 8, 2025 11:10
@ahmed3mar ahmed3mar requested a review from a team as a code owner February 8, 2025 11:10
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean removing unused service_providers from config/app.go? Yes, this PR should optimize that situation, great catch! How about moving this file to contracts/binding.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's better there

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Great PR

type ServiceProvider struct {
}

func (database *ServiceProvider) Register(app foundation.Application) {
app.BindWith(BindingAuth, func(app foundation.Application, parameters map[string]any) (any, error) {
func (auth *ServiceProvider) Register(app foundation.Application) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

@hwbrzzl hwbrzzl merged commit 01b1b9d into goravel:v1.15.x Feb 9, 2025
12 of 13 checks passed
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.

2 participants