Skip to content

Feat/grpc tls#218

Merged
thorrester merged 4 commits intomainfrom
feat/grpc-tls
Mar 3, 2026
Merged

Feat/grpc tls#218
thorrester merged 4 commits intomainfrom
feat/grpc-tls

Conversation

@thorrester
Copy link
Member

Summary

Adds TLS support and connection tuning options to the gRPC transport layer.

TLS

The gRPC client now automatically negotiates TLS based on the URI scheme. Connections to https:// endpoints use native system roots; http:// connections remain plaintext. No config flag required — URI scheme drives the behavior.

Connection options

GrpcConfig gains five new optional fields for fine-grained connection control:

Field Default Description
timeout_secs None (no limit) Per-request response timeout
connect_timeout_secs None (no limit) Initial connection establishment timeout
keep_alive_interval_secs None (disabled) HTTP/2 keepalive ping interval
keep_alive_timeout_secs None (disabled) Time to wait for keepalive ping response
keep_alive_while_idle None (disabled) Send keepalives even with no active streams

All fields are optional and default to the previous behavior (no timeouts, no keepalives).

Internal refactor

  • Extracted build_channel as a standalone async function — centralizes endpoint construction and TLS branching, removes duplication between GrpcClient::new and health_check.
  • health_check now reuses the existing Channel stored on the client instead of opening a new connection per call.
  • Channel is stored on GrpcClient to support channel reuse across all service clients.

Changes

  • crates/scouter_settings/src/grpc.rs — added five new fields to GrpcConfig and its constructor
  • crates/scouter_tonic/src/client.rsbuild_channel function with TLS detection and connection option application; Channel
    stored on GrpcClient; health_check reuses stored channel
  • py-scouter/python/scouter/_scouter.pyi / stubs/scouter.pyi — updated stubs with new GrpcConfig fields and docstrings

Usage

from scouter import GrpcConfig

# TLS with keepalives (recommended for cloud deployments)
config = GrpcConfig(
    server_uri="https://scouter.example.com:443",
    username="user",
    password="pass",
    connect_timeout_secs=10,
    timeout_secs=30,
    keep_alive_interval_secs=20,
    keep_alive_timeout_secs=5,
    keep_alive_while_idle=True,
)

@thorrester thorrester marked this pull request as ready for review March 3, 2026 22:37
@thorrester thorrester merged commit a323b3b into main Mar 3, 2026
24 checks passed
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.59%. Comparing base (b82477a) to head (ffca52c).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #218   +/-   ##
=======================================
  Coverage   62.59%   62.59%           
=======================================
  Files          18       18           
  Lines         262      262           
=======================================
  Hits          164      164           
  Misses         98       98           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants