Skip to content

Conversation

@devhaozi
Copy link
Member

πŸ“‘ Description

For issue goravel/goravel#436

@coderabbitai summary

βœ… Checks

  • Added test cases for my code

@devhaozi devhaozi requested a review from a team as a code owner December 16, 2024 08:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • πŸš€ Review Ready

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.

@devhaozi devhaozi closed this Dec 16, 2024
@devhaozi devhaozi reopened this Dec 16, 2024
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: 6b29c5d Previous: 44c5de1 Ratio
BenchmarkFile_ReadWrite 283804 ns/op 2072 B/op 27 allocs/op 181467 ns/op 2072 B/op 27 allocs/op 1.56
BenchmarkFile_ReadWrite - ns/op 283804 ns/op 181467 ns/op 1.56

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

@codecov
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 69.88%. Comparing base (9dddb62) to head (8eed87d).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #762   +/-   ##
=======================================
  Coverage   69.88%   69.88%           
=======================================
  Files         212      212           
  Lines       17890    17890           
=======================================
  Hits        12503    12503           
  Misses       4708     4708           
  Partials      679      679           

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

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.

Could you introduce how to use this method and what the change of main.go is?

@devhaozi
Copy link
Member Author

Could you introduce how to use this method and what the change of main.go is?

for gin

image

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

Okay, what's the change of main.go?

@devhaozi
Copy link
Member Author

devhaozi commented Dec 16, 2024

Okay, what's the change of main.go?

Similar to this

	upg, err := tableflip.New(tableflip.Options{})
	if err != nil {
		panic(err)
	}
	defer upg.Stop()

	// Listen for the process signal to trigger the tableflip upgrade.
	go func() {
		sig := make(chan os.Signal, 1)
		signal.Notify(sig, syscall.SIGHUP)
		for range sig {
			if err = upg.Upgrade(); err != nil {
				facades.Log().Errorf("[Graceful] upgrade failed: %v", err)
			}
		}
	}()

	ln, err := upg.Listen("tcp", ":3000")
	if err != nil {
		panic(err)
	}
	defer ln.Close()

	go func() {
		if err = facades.Route().Run(); err != nil {
			facades.Log().Errorf("Route run error: %v", err)
		}
	}()

	// tableflip ready
	if err = upg.Ready(); err != nil {
		panic(err)
	}

	facades.Log().Infof("[Graceful] ready for upgrade")
	<-upg.Exit() // This will block main, so select{} is no longer needed

	// Wait for connections to drain.
	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
	defer cancel()

	log.Println("[Graceful] shutting down")
	return facades.Route().Shutdown(ctx)

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

Oh, so complicated, can we wrap it?

@devhaozi
Copy link
Member Author

Oh, so complicated, can we wrap it?

Seems unnecessary, users may not use graceful restart.

@devhaozi devhaozi closed this Dec 16, 2024
@devhaozi devhaozi reopened this Dec 16, 2024
@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

I think this PR is solving the interruption when upgrading the application, it's unnecessary if User is using K8S, because K8S can build new pods before destroying the old ones. But if User launches the application directly instead of K8S, this feature will be useful.

Currently, User have to launch the latest version with a different port and use Nginx to listen to it, otherwise, there is a short interruption during the upgrade.

Comment on lines 29 to 30
// Stop gracefully stop the serve.
Stop(ctx ...context.Context) error
Copy link
Member Author

Choose a reason for hiding this comment

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

Q: I think it would be better to rename this method to Shutdown, which is what both the std library and go-fiber do.

Copy link
Contributor

Choose a reason for hiding this comment

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

It was Shutdown previously, however, we are going to add Stop method to Schedule, Queue, and Testing.Database, so I changed it to Stop. But now, I think Shutdown is better, it means functions are closed gracefully. πŸ‘ I'll create a PR for it.

@devhaozi
Copy link
Member Author

devhaozi commented Dec 16, 2024

I think this PR is solving the interruption when upgrading the application, it's unnecessary if User is using K8S, because K8S can build new pods before destroying the old ones. But if User launches the application directly instead of K8S, this feature will be useful.

Currently, User have to launch the latest version with a different port and use Nginx to listen to it, otherwise, there is a short interruption during the upgrade.

After using https://github.com/cloudflare/tableflip , only need to send HUP single to application, then it will restart automatically.

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

Yes, cloudflare/tableflip is a good feature, it should be better if we can wrap the complicated logic and use a simple way to implement it.

@devhaozi
Copy link
Member Author

Yes, cloudflare/tableflip is a good feature, it should be better if we can wrap the complicated logic and use a simple way to implement it.

You mean direct use tableflip in there?

image

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

Maybe, if we can.

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

Or just a few changes in main.go

@devhaozi
Copy link
Member Author

Yes, cloudflare/tableflip is a good feature, it should be better if we can wrap the complicated logic and use a simple way to implement it.

You mean direct use tableflip in there?

image

But the select{} here will prevent tableflip from running.
image

@hwbrzzl
Copy link
Contributor

hwbrzzl commented Dec 16, 2024

select{} can be removed if needed. We can make a minimal implement first, to check the logic is expected.

@devhaozi devhaozi closed this Dec 17, 2024
@devhaozi devhaozi reopened this Dec 17, 2024
@devhaozi devhaozi enabled auto-merge (squash) December 17, 2024 03:09
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

@devhaozi devhaozi merged commit 003a287 into master Dec 17, 2024
11 checks passed
@devhaozi devhaozi deleted the haozi/listen branch December 17, 2024 03:53
hwbrzzl added a commit that referenced this pull request Sep 6, 2025
hwbrzzl added a commit that referenced this pull request Sep 6, 2025
* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint
hwbrzzl added a commit that referenced this pull request Sep 6, 2025
hwbrzzl added a commit that referenced this pull request Sep 19, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix typo

---------

Co-authored-by: krishan kumar <[email protected]>
Co-authored-by: ALMAS <[email protected]>
hwbrzzl added a commit that referenced this pull request Oct 26, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix: comand cannot be run concurrently (#1243)

* fix: comand cannot be run concurrently

* fix ci

* fix ci

* optimize

* optimize

* optimize

* optimize

* optimize global options

* fix ci

* upgrade v1.16.4

* optimize

* optimize

---------

Co-authored-by: krishan kumar <[email protected]>
Co-authored-by: ALMAS <[email protected]>
hwbrzzl added a commit that referenced this pull request Oct 31, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix: comand cannot be run concurrently (#1243)

* fix: comand cannot be run concurrently

* fix ci

* fix ci

* optimize

* optimize

* optimize

* optimize

* optimize global options

* fix ci

* upgrade v1.16.4

* fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252)

* fix: [#807] queue.Shutdown doesn't stop the queue as expected

* optimize

* upgrade: v1.16.5

* fix

* Update queue/worker_test.go

Co-authored-by: Copilot <[email protected]>

* optimize

---------

Co-authored-by: krishan kumar <[email protected]>
Co-authored-by: ALMAS <[email protected]>
Co-authored-by: Copilot <[email protected]>
hwbrzzl added a commit that referenced this pull request Oct 31, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix: comand cannot be run concurrently (#1243)

* fix: comand cannot be run concurrently

* fix ci

* fix ci

* optimize

* optimize

* optimize

* optimize

* optimize global options

* fix ci

* upgrade v1.16.4

* fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252)

* fix: [#807] queue.Shutdown doesn't stop the queue as expected

* optimize

* upgrade: v1.16.5

* fix

* Update queue/worker_test.go

Co-authored-by: Copilot <[email protected]>

* optimize

---------

Co-authored-by: krishan kumar <[email protected]>
Co-authored-by: ALMAS <[email protected]>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants