Skip to content

Conversation

currantw
Copy link
Collaborator

@currantw currantw commented Oct 10, 2025

Summary

Adds support for lazy connection to the Valkey Glide C# client.

Description

This pull request add support for lazy connection to the Valkey Glide C# client. When lazy connect is enabled, the client is initialized without establishing network connections to the Valkey servers; instead, connections are only created when the first command is executed.

See Lazy Connect - Valkey Glide Wiki for more details, including how lazy connect works and important considerations.

Changes

  • Update BaseClient and subclasses to lazily determine the server version. See description here of why this is necessary to enabled lazy connect.
  • Add LazyConnect attribute to ConnectionConfiguration, StandaloneClientConfiguration, ClusterClientConfiguration, and ClientConfigurationBuilder.
  • Add lazyConnect attribute to ConnectionConfig internal FFI struct.
  • Add EagerConnect and LazyConnect tests to ClusterClientTests and StandaloneClientTests.
  • Add ServerManager test helper class for adding/removing servers during integration tests.
  • Add ConnectionInfo test helper class for retrieving the number of clients connected to a server.

Related Issues

@currantw currantw requested a review from a team as a code owner October 10, 2025 23:48
@currantw currantw force-pushed the currantw/lazy-connect branch from 14b0978 to 9eef6a5 Compare October 10, 2025 23:52
@currantw currantw force-pushed the currantw/lazy-connect branch from 87773ca to d279437 Compare October 13, 2025 18:28
@currantw currantw self-assigned this Oct 14, 2025
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 pull request adds lazy connection support to the Valkey Glide C# client, allowing clients to defer network connections until the first command is executed instead of establishing connections during initialization.

Key changes:

  • Added LazyConnect configuration option to client builders and configuration classes
  • Modified server version determination to be lazy rather than happening during client initialization
  • Added comprehensive integration tests to verify lazy vs eager connection behavior

Reviewed Changes

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

Show a summary per file
File Description
tests/Valkey.Glide.IntegrationTests/TestUtils.cs New utility class for counting client connections in tests
tests/Valkey.Glide.IntegrationTests/StandaloneClientTests.cs Added lazy and eager connection tests for standalone client
tests/Valkey.Glide.IntegrationTests/ClusterClientTests.cs Added lazy and eager connection tests for cluster client
sources/Valkey.Glide/Internals/FFI.structs.cs Added LazyConnect field to FFI connection configuration
sources/Valkey.Glide/GlideClusterClient.cs Refactored server version initialization to be lazy
sources/Valkey.Glide/GlideClient.cs Refactored server version initialization to be lazy
sources/Valkey.Glide/ConnectionConfiguration.cs Added LazyConnect property and methods to configuration classes
sources/Valkey.Glide/BaseClient.cs Modified client creation flow and extracted common server version parsing
sources/Valkey.Glide/BaseClient.GenericCommands.cs Updated to use lazy server version retrieval
rust/src/ffi.rs Updated Rust FFI to handle lazy connect configuration
DEVELOPER.md Fixed typo in filename reference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@currantw currantw force-pushed the currantw/lazy-connect branch from 1d63c4d to fa101c4 Compare October 17, 2025 17:33
Copy link
Collaborator

@jbrinkman jbrinkman left a comment

Choose a reason for hiding this comment

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

A few small changes.

@currantw currantw force-pushed the currantw/lazy-connect branch from fa101c4 to b4e94cc Compare October 21, 2025 16:31
@currantw currantw force-pushed the currantw/lazy-connect branch from 7b35862 to a05ed57 Compare October 21, 2025 16:47
Copy link
Collaborator

@jbrinkman jbrinkman left a comment

Choose a reason for hiding this comment

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

:shipit:

@currantw currantw merged commit ee1efed into valkey-io:main Oct 22, 2025
11 checks passed
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