Skip to content

Commit 0cf4a7e

Browse files
committed
Address GitHub Copilot review comments.
Signed-off-by: currantw <[email protected]>
1 parent 2324b50 commit 0cf4a7e

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
@@ -786,50 +786,50 @@ internal struct NodeAddress
786786
}
787787

788788
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
789-
internal struct AuthenticationInfo(string? username, string? password, IamCredentials? iamCredentials)
789+
internal readonly struct AuthenticationInfo(string? username, string? password, IamCredentials? iamCredentials)
790790
{
791791
/// <summary>
792792
/// Username for authentication.
793793
/// </summary>
794794
[MarshalAs(UnmanagedType.LPStr)]
795-
public string? Username = username;
795+
public readonly string? Username = username;
796796

797797
/// <summary>
798798
/// Password for authentication.
799799
/// </summary>
800800
[MarshalAs(UnmanagedType.LPStr)]
801-
public string? Password = password;
801+
public readonly string? Password = password;
802802

803803
/// <summary>
804804
/// IAM credentials for authentication.
805805
/// </summary>
806-
public IamCredentials? IamCredentials = iamCredentials;
806+
public readonly IamCredentials? IamCredentials = iamCredentials;
807807
}
808808

809809
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
810-
internal struct IamCredentials(string clusterName, string region, ServiceType serviceType, uint? refreshIntervalSeconds)
810+
internal readonly struct IamCredentials(string clusterName, string region, ServiceType serviceType, uint? refreshIntervalSeconds)
811811
{
812812
/// <summary>
813813
/// The name of the cluster for IAM authentication.
814814
/// </summary>
815815
[MarshalAs(UnmanagedType.LPStr)]
816-
public string ClusterName = clusterName;
816+
public readonly string ClusterName = clusterName;
817817

818818
/// <summary>
819819
/// The AWS region for IAM authentication.
820820
/// </summary>
821821
[MarshalAs(UnmanagedType.LPStr)]
822-
public string Region = region;
822+
public readonly string Region = region;
823823

824824
/// <summary>
825825
/// The AWS service type for IAM authentication.
826826
/// </summary>
827-
public ServiceType ServiceType = serviceType;
827+
public readonly ServiceType ServiceType = serviceType;
828828

829829
/// <summary>
830830
/// The refresh interval in seconds for IAM authentication.
831831
/// </summary>
832-
public uint? RefreshIntervalSeconds = refreshIntervalSeconds;
832+
public readonly uint? RefreshIntervalSeconds = refreshIntervalSeconds;
833833
}
834834

835835
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)