Skip to content

feat: Add lib_name and client_info_tag to client configuration - #1

Closed
Jonathan-Improving wants to merge 3 commits into
mainfrom
feature/client-info-tag
Closed

Jonathan-Improving wants to merge 3 commits into
mainfrom
feature/client-info-tag

Conversation

@Jonathan-Improving

Copy link
Copy Markdown
Owner

Internal Review

Soliciting internal review before finalizing the upstream draft PR.

Upstream draft: valkey-io#292
Jira: AEA-632
Parent issue: valkey-io/valkey-glide#6429

Summary

Adds lib_name and client_info_tag parameters to the PHP GLIDE client constructor. When client_info_tag is set, it appends a parenthesized tag to the library name sent via CLIENT SETINFO LIB-NAME (e.g. GlidePHP(my-framework:1.0)).

Behavior

Config Resulting lib-name
(none) GlidePHP (default)
client_info_tag="foo" GlidePHP(foo)
lib_name="custom" custom
lib_name="custom" + client_info_tag="foo" custom(foo)

Implementation notes

  • Changes span PHP stubs and C extension code
  • Whitespace validation done at C level
  • Follows existing client_name pattern through FFI

Review focus

  • C extension parameter parsing and validation
  • PHP stub signatures and docblocks
  • Test coverage

Commits will likely be squashed before pushing upstream.

Add two new parameters to the ValkeyGlide and ValkeyGlideCluster connect()
methods:

- lib_name: Full override for the CLIENT SETINFO LIB-NAME value
  (default: 'GlidePHP' set by Rust core when NULL)
- client_info_tag: Tag appended as 'GlidePHP(tag)' for framework
  attribution without losing GLIDE identity

Behavior matrix:
| Config                              | Resulting lib-name          |
|-------------------------------------|-----------------------------|
| (none)                              | GlidePHP (Rust core default)|
| client_info_tag='fw:1.0'            | GlidePHP(fw:1.0)            |
| lib_name='custom'                   | custom                      |
| lib_name='custom', tag='fw:1.0'     | custom(fw:1.0)              |

Validation: client_info_tag rejects whitespace (space, tab, newline, CR)
with ValkeyGlideException.

Passes lib_name to ConnectionRequest protobuf field 19, consumed by
Rust core for CLIENT SETINFO LIB-NAME during connection establishment.

Includes unit tests (ConnectionRequestTest) and integration tests
(ValkeyGlideFeaturesTest).

Refs: valkey-io/valkey-glide#6389 (Python reference implementation)
Signed-off-by: extollIT Enterprises <support@extollit.com>

@MatthiasHowellYopp MatthiasHowellYopp left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

APPROVE (with nits)

Clean, well-implemented PR. The C extension code is memory-safe, parameter handling is correct, and the implementation aligns with the upstream Python reference (valkey-io/valkey-glide#6389). No blocking issues.

ℹ️ CI not triggered — no checks reported on this branch.


public function testConstructorWithSingleAddress()
{
// Test constructor with single address in proper array format

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Warning: Missing cluster integration tests

The integration tests here only exercise the standalone ValkeyGlide client. The ValkeyGlideCluster.__construct also accepts lib_name/client_info_tag, but there's no end-to-end test verifying CLIENT INFO output for the cluster client.

The unit tests in ConnectionRequestTest.php cover protobuf serialization for both paths, so this isn't blocking — but consider adding at least one cluster integration test (e.g., in ValkeyGlideClusterFeaturesTest.php) before pushing upstream.

@@ -120,6 +122,21 @@ PHP_METHOD(ClientConstructorMock, simulate_standalone_constructor) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💅 Nit: Double blank line before the validation block. The rest of the file uses single blank lines between logical sections.

Suggested change
/* Validate client_info_tag contains no whitespace */

conn_req.client_name = config->client_name ? config->client_name : NULL;

/* Set lib_name: compose from lib_name override and/or client_info_tag */
char* composed_lib_name = NULL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💅 Nit (edge case): The composition logic uses if (config->lib_name && config->client_info_tag) which is truthy for an empty string "" (non-NULL pointer). With lib_name="" + client_info_tag="foo", the result would be "(foo)" — a bare open paren with no prefix.

Unlikely in practice (callers pass null for unset), and the Python reference doesn't guard against this either. Just documenting — no action needed unless you want to add a strlen > 0 check for symmetry.

- F-PHP-001: Replace manual char checks with isspace() covering \v and \f
- F-PHP-002: Extract validate_client_info_tag() into common.h, called by all 4 sites

Signed-off-by: Jonathan Neufeld <jonathan.neufeld@improving.com>
Signed-off-by: Jonathan Neufeld <jonathan.neufeld@improving.com>
@Jonathan-Improving

Copy link
Copy Markdown
Owner Author

Superseded by valkey-io#292

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