Skip to content

Conversation

@Snider
Copy link
Owner

@Snider Snider commented Feb 2, 2026

This change introduces connection pooling, keep-alive, and HTTP/2 support to the website collector. It adds a new httpclient package to create a configurable http.Client and exposes the configuration options as command-line flags. It also adds connection reuse metrics to the output of the collect website command.

Fixes #56


PR created automatically by Jules for task 16526616877032749391 started by @Snider

This change introduces connection pooling, keep-alive, and HTTP/2 support to the website collector. It adds a new httpclient package to create a configurable http.Client and exposes the configuration options as command-line flags. It also adds connection reuse metrics to the output of the collect website command.

Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Warning

Rate limit exceeded

@Snider has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/connection-pooling-16526616877032749391

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Snider, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly upgrades the collect website command by integrating advanced HTTP client capabilities. The primary goal is to improve the efficiency and speed of web data collection through optimized network interactions. By centralizing HTTP client configuration and exposing these settings via command-line flags, the changes offer greater control and transparency over how the collector manages its network connections. This enhancement is crucial for handling large-scale web crawling more effectively.

Highlights

  • Connection Pooling and Keep-Alive: The website collector now leverages connection pooling and keep-alive mechanisms to enhance performance and optimize resource utilization for HTTP requests.
  • Configurable HTTP Client: A new httpclient package has been introduced, providing a highly configurable http.Client with options for managing maximum connections per host, idle connection timeouts, and more.
  • HTTP/2 Support: The new HTTP client infrastructure inherently supports HTTP/2 by default, with an explicit option to force HTTP/1.1 if required.
  • Command-Line Configuration: New command-line flags (--max-connections, --no-keepalive, --http1, --idle-timeout, --max-idle) have been added to the collect website command, allowing users to fine-tune HTTP client behavior.
  • Connection Reuse Metrics: The collect website command now outputs detailed metrics on connection reuse, showing the number of connections that were reused versus newly created, providing insights into network efficiency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces connection pooling and keep-alive support, which is a great enhancement for the website collector. A new httpclient package is added to provide a configurable http.Client, and new flags are exposed in the collect_website command. The implementation is solid, especially the use of httptrace for metrics. I have a couple of suggestions for improvement: one regarding error handling for the new command-line flags, and another to make the HTTP transport initialization more robust by building upon Go's default transport.

Comment on lines +43 to +47
maxConnections, _ := cmd.Flags().GetInt("max-connections")
noKeepAlive, _ := cmd.Flags().GetBool("no-keepalive")
http1, _ := cmd.Flags().GetBool("http1")
idleTimeout, _ := cmd.Flags().GetDuration("idle-timeout")
maxIdle, _ := cmd.Flags().GetInt("max-idle")

Choose a reason for hiding this comment

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

high

The errors returned from parsing these new command-line flags are being ignored. If a user provides an invalid value for any of these flags (e.g., --max-connections=foo), the error will be discarded, and the variable will be assigned its zero value. This can lead to the application running with an unintended configuration without any warning. The errors should be checked and returned to the user, so they are aware of the issue.

			maxConnections, err := cmd.Flags().GetInt("max-connections")
			if err != nil {
				return err
			}
			noKeepAlive, err := cmd.Flags().GetBool("no-keepalive")
			if err != nil {
				return err
			}
			http1, err := cmd.Flags().GetBool("http1")
			if err != nil {
				return err
			}
			idleTimeout, err := cmd.Flags().GetDuration("idle-timeout")
			if err != nil {
				return err
			}
			maxIdle, err := cmd.Flags().GetInt("max-idle")
			if err != nil {
				return err
			}

Comment on lines +30 to +41
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
MaxIdleConns: opts.MaxIdle,
IdleConnTimeout: opts.IdleTimeout,
TLSHandshakeTimeout: 10 * time.Second,
MaxConnsPerHost: opts.MaxPerHost,
DisableKeepAlives: opts.NoKeepAlive,
}

Choose a reason for hiding this comment

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

medium

Instead of creating a new http.Transport from scratch, it's better practice to clone http.DefaultTransport. This ensures that you start with a known-good configuration with sensible defaults (like ForceAttemptHTTP2 for HTTP/2 support, which this PR aims to add) and then customize it. Re-implementing the defaults can lead to missing out on important settings or future improvements to DefaultTransport.

	transport := http.DefaultTransport.(*http.Transport).Clone()
	transport.MaxIdleConns = opts.MaxIdle
	transport.IdleConnTimeout = opts.IdleTimeout
	transport.MaxConnsPerHost = opts.MaxPerHost
	transport.DisableKeepAlives = opts.NoKeepAlive

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.

feat: Connection pooling and keep-alive

2 participants