Skip to content

Commit 01d5d8b

Browse files
committed
Address GitHub Copilot review comments.
Signed-off-by: currantw <[email protected]>
1 parent f1454e0 commit 01d5d8b

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,19 @@ Console.WriteLine($"User: {user}");
101101
var passwordConfig = new StandaloneClientConfigurationBuilder()
102102
.WithAddress(host, port)
103103
.WithAuthentication("username", "password")
104-
.WithTls(false)
104+
.WithTls()
105105
.Build();
106106

107-
using var client = await GlideClient.CreateClient(passwordConfig);
107+
using var passwordClient = await GlideClient.CreateClient(passwordConfig);
108108

109109
// IAM authentication.
110+
var iamAuthConfig = new IamAuthConfig("my-cluster", ServiceType.ElastiCache, "us-east-1");
110111
var iamConfig = new ClusterClientConfigurationBuilder()
111112
.WithAddress(host, port)
112-
.WithAuthentication("username", "my-cluster", ServiceType.ElastiCache, "us-east-1")
113+
.WithAuthentication("username", iamAuthConfig)
113114
.Build();
114115

115-
using var client = await GlideClient.CreateClient(iamConfig);
116+
using var iamClient = await GlideClient.CreateClient(iamConfig);
116117
```
117118

118119
## Core API Examples

sources/Valkey.Glide/BaseClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public void Dispose()
4545
/// <returns>A task that completes when the refresh attempt finishes.</returns>
4646
public async Task RefreshIamTokenAsync()
4747
{
48-
Message message = _messageContainer.GetMessageForCall();
49-
RefreshIamTokenFfi(_clientPointer, (ulong)message.Index);
48+
Message message = MessageContainer.GetMessageForCall();
49+
RefreshIamTokenFfi(ClientPointer, (ulong)message.Index);
5050
IntPtr response = await message;
5151
try
5252
{

sources/Valkey.Glide/Internals/FFI.structs.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -797,50 +797,50 @@ internal struct NodeAddress
797797
}
798798

799799
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
800-
internal struct AuthenticationInfo(string? username, string? password, IamCredentials? iamCredentials)
800+
internal readonly struct AuthenticationInfo(string? username, string? password, IamCredentials? iamCredentials)
801801
{
802802
/// <summary>
803803
/// Username for authentication.
804804
/// </summary>
805805
[MarshalAs(UnmanagedType.LPStr)]
806-
public string? Username = username;
806+
public readonly string? Username = username;
807807

808808
/// <summary>
809809
/// Password for authentication.
810810
/// </summary>
811811
[MarshalAs(UnmanagedType.LPStr)]
812-
public string? Password = password;
812+
public readonly string? Password = password;
813813

814814
/// <summary>
815815
/// IAM credentials for authentication.
816816
/// </summary>
817-
public IamCredentials? IamCredentials = iamCredentials;
817+
public readonly IamCredentials? IamCredentials = iamCredentials;
818818
}
819819

820820
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
821-
internal struct IamCredentials(string clusterName, string region, ServiceType serviceType, uint? refreshIntervalSeconds)
821+
internal readonly struct IamCredentials(string clusterName, string region, ServiceType serviceType, uint? refreshIntervalSeconds)
822822
{
823823
/// <summary>
824824
/// The name of the cluster for IAM authentication.
825825
/// </summary>
826826
[MarshalAs(UnmanagedType.LPStr)]
827-
public string ClusterName = clusterName;
827+
public readonly string ClusterName = clusterName;
828828

829829
/// <summary>
830830
/// The AWS region for IAM authentication.
831831
/// </summary>
832832
[MarshalAs(UnmanagedType.LPStr)]
833-
public string Region = region;
833+
public readonly string Region = region;
834834

835835
/// <summary>
836836
/// The AWS service type for IAM authentication.
837837
/// </summary>
838-
public ServiceType ServiceType = serviceType;
838+
public readonly ServiceType ServiceType = serviceType;
839839

840840
/// <summary>
841841
/// The refresh interval in seconds for IAM authentication.
842842
/// </summary>
843-
public uint? RefreshIntervalSeconds = refreshIntervalSeconds;
843+
public readonly uint? RefreshIntervalSeconds = refreshIntervalSeconds;
844844
}
845845

846846
internal enum ServiceType : uint

tests/Valkey.Glide.UnitTests/ConnectionConfigurationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void WithAuthentication_MultipleCalls_LastWins()
7777
{
7878
// Password-based authentication last.
7979
var builder = new StandaloneClientConfigurationBuilder();
80-
var iamConfig = new IamAuthConfig(ClusterName, ServiceType.ElastiCache, Region, RefreshIntervalSeconds);
80+
var iamConfig = new IamAuthConfig(ClusterName, ServiceType.MemoryDB, Region);
8181
builder.WithAuthentication(Username, iamConfig);
8282
builder.WithAuthentication(Username, Password);
8383

0 commit comments

Comments
 (0)