Skip to content

Commit 14ff1b0

Browse files
committed
* Replace CachedString with new types.
1 parent aa9ee8b commit 14ff1b0

File tree

9 files changed

+20
-88
lines changed

9 files changed

+20
-88
lines changed

projects/RabbitMQ.Client/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,6 @@ RabbitMQ.Client.BinaryTableValue.BinaryTableValue() -> void
186186
RabbitMQ.Client.BinaryTableValue.BinaryTableValue(byte[] bytes) -> void
187187
RabbitMQ.Client.BinaryTableValue.Bytes.get -> byte[]
188188
RabbitMQ.Client.BinaryTableValue.Bytes.set -> void
189-
RabbitMQ.Client.CachedString
190-
RabbitMQ.Client.CachedString.CachedString(string value) -> void
191-
RabbitMQ.Client.CachedString.CachedString(string value, System.ReadOnlyMemory<byte> bytes) -> void
192-
RabbitMQ.Client.CachedString.CachedString(System.ReadOnlyMemory<byte> bytes) -> void
193189
RabbitMQ.Client.ConnectionConfig
194190
RabbitMQ.Client.ConnectionConfig.CredentialsProvider -> RabbitMQ.Client.ICredentialsProvider
195191
RabbitMQ.Client.ConnectionConfig.CredentialsRefresher -> RabbitMQ.Client.ICredentialsRefresher
@@ -481,7 +477,7 @@ RabbitMQ.Client.IChannel.BasicAckAsync(ulong deliveryTag, bool multiple, System.
481477
RabbitMQ.Client.IChannel.BasicAcks -> System.EventHandler<RabbitMQ.Client.Events.BasicAckEventArgs>
482478
RabbitMQ.Client.IChannel.BasicNackAsync(ulong deliveryTag, bool multiple, bool requeue, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
483479
RabbitMQ.Client.IChannel.BasicNacks -> System.EventHandler<RabbitMQ.Client.Events.BasicNackEventArgs>
484-
RabbitMQ.Client.IChannel.BasicPublishAsync<TProperties>(RabbitMQ.Client.CachedString! exchange, RabbitMQ.Client.CachedString! routingKey, TProperties basicProperties, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
480+
RabbitMQ.Client.IChannel.BasicPublishAsync<TProperties>(RabbitMQ.Client.ExchangeName! exchange, RabbitMQ.Client.RoutingKey! routingKey, TProperties basicProperties, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
485481
RabbitMQ.Client.IChannel.BasicPublishAsync<TProperties>(string! exchange, string! routingKey, TProperties basicProperties, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask
486482
RabbitMQ.Client.IChannel.BasicReturn -> System.EventHandler<RabbitMQ.Client.Events.BasicReturnEventArgs>
487483
RabbitMQ.Client.IChannel.CallbackException -> System.EventHandler<RabbitMQ.Client.Events.CallbackExceptionEventArgs>
@@ -780,8 +776,6 @@ readonly RabbitMQ.Client.BasicGetResult.Exchange -> string
780776
readonly RabbitMQ.Client.BasicGetResult.MessageCount -> uint
781777
readonly RabbitMQ.Client.BasicGetResult.Redelivered -> bool
782778
readonly RabbitMQ.Client.BasicGetResult.RoutingKey -> string
783-
readonly RabbitMQ.Client.CachedString.Bytes -> System.ReadOnlyMemory<byte>
784-
readonly RabbitMQ.Client.CachedString.Value -> string
785779
readonly RabbitMQ.Client.ConnectionConfig.AuthMechanisms -> System.Collections.Generic.IEnumerable<RabbitMQ.Client.IAuthMechanismFactory>
786780
readonly RabbitMQ.Client.ConnectionConfig.ClientProperties -> System.Collections.Generic.IDictionary<string, object>
787781
readonly RabbitMQ.Client.ConnectionConfig.ClientProvidedName -> string
@@ -847,8 +841,8 @@ static RabbitMQ.Client.EndpointResolverExtensions.SelectOneAsync<T>(this RabbitM
847841
static RabbitMQ.Client.Events.CallbackExceptionEventArgs.Build(System.Exception e, string context) -> RabbitMQ.Client.Events.CallbackExceptionEventArgs
848842
static RabbitMQ.Client.Events.CallbackExceptionEventArgs.Build(System.Exception e, string context, object consumer) -> RabbitMQ.Client.Events.CallbackExceptionEventArgs
849843
static RabbitMQ.Client.ExchangeType.All() -> System.Collections.Generic.ICollection<string>
850-
static RabbitMQ.Client.IChannelExtensions.BasicPublishAsync(this RabbitMQ.Client.IChannel channel, RabbitMQ.Client.CachedString exchange, RabbitMQ.Client.CachedString routingKey, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false) -> System.Threading.Tasks.ValueTask
851844
static RabbitMQ.Client.IChannelExtensions.BasicPublishAsync(this RabbitMQ.Client.IChannel channel, string exchange, string routingKey, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false) -> System.Threading.Tasks.ValueTask
845+
static RabbitMQ.Client.IChannelExtensions.BasicPublishAsync(this RabbitMQ.Client.IChannel! channel, RabbitMQ.Client.ExchangeName! exchange, RabbitMQ.Client.RoutingKey! routingKey, System.ReadOnlyMemory<byte> body = default(System.ReadOnlyMemory<byte>), bool mandatory = false) -> System.Threading.Tasks.ValueTask
852846
static RabbitMQ.Client.IChannelExtensions.BasicPublishAsync<T>(this RabbitMQ.Client.IChannel channel, RabbitMQ.Client.PublicationAddress addr, in T basicProperties, System.ReadOnlyMemory<byte> body) -> System.Threading.Tasks.ValueTask
853847
static RabbitMQ.Client.PublicationAddress.Parse(string uriLikeString) -> RabbitMQ.Client.PublicationAddress
854848
static RabbitMQ.Client.PublicationAddress.TryParse(string uriLikeString, out RabbitMQ.Client.PublicationAddress result) -> bool
@@ -857,7 +851,6 @@ static RabbitMQ.Client.RabbitMQActivitySource.UseRoutingKeyAsOperationName.get -
857851
static RabbitMQ.Client.RabbitMQActivitySource.UseRoutingKeyAsOperationName.set -> void
858852
static RabbitMQ.Client.TcpClientAdapter.GetMatchingHost(System.Collections.Generic.IReadOnlyCollection<System.Net.IPAddress> addresses, System.Net.Sockets.AddressFamily addressFamily) -> System.Net.IPAddress
859853
static RabbitMQ.Client.TimerBasedCredentialRefresherEventSource.Log.get -> RabbitMQ.Client.TimerBasedCredentialRefresherEventSource
860-
static readonly RabbitMQ.Client.CachedString.Empty -> RabbitMQ.Client.CachedString
861854
static readonly RabbitMQ.Client.ConnectionFactory.DefaultAuthMechanisms -> System.Collections.Generic.IEnumerable<RabbitMQ.Client.IAuthMechanismFactory>
862855
static readonly RabbitMQ.Client.ConnectionFactory.DefaultConnectionTimeout -> System.TimeSpan
863856
static readonly RabbitMQ.Client.ConnectionFactory.DefaultCredentialsRefresher -> RabbitMQ.Client.ICredentialsRefresher

projects/RabbitMQ.Client/client/api/CachedString.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

projects/RabbitMQ.Client/client/api/IChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ ValueTask BasicPublishAsync<TProperties>(string exchange, string routingKey, TPr
224224
/// <remarks>
225225
/// Routing key must be shorter than 255 bytes.
226226
/// </remarks>
227-
ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey, TProperties basicProperties,
227+
ValueTask BasicPublishAsync<TProperties>(ExchangeName exchange, RoutingKey routingKey, TProperties basicProperties,
228228
ReadOnlyMemory<byte> body = default, bool mandatory = false,
229229
CancellationToken cancellationToken = default)
230230
where TProperties : IReadOnlyBasicProperties, IAmqpHeader;

projects/RabbitMQ.Client/client/api/IChannelExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ public static ValueTask BasicPublishAsync<T>(this IChannel channel, PublicationA
9393
return channel.BasicPublishAsync(addr.ExchangeName, addr.RoutingKey, basicProperties, body);
9494
}
9595

96-
public static ValueTask BasicPublishAsync(this IChannel channel, string exchange, string routingKey, ReadOnlyMemory<byte> body = default, bool mandatory = false)
96+
public static ValueTask BasicPublishAsync(this IChannel channel, string exchange, string routingKey,
97+
ReadOnlyMemory<byte> body = default, bool mandatory = false)
9798
=> channel.BasicPublishAsync(exchange, routingKey, EmptyBasicProperty.Empty, body, mandatory);
9899

99-
public static ValueTask BasicPublishAsync(this IChannel channel, CachedString exchange, CachedString routingKey, ReadOnlyMemory<byte> body = default, bool mandatory = false)
100+
public static ValueTask BasicPublishAsync(this IChannel channel, ExchangeName exchange, RoutingKey routingKey,
101+
ReadOnlyMemory<byte> body = default, bool mandatory = false)
100102
=> channel.BasicPublishAsync(exchange, routingKey, EmptyBasicProperty.Empty, body, mandatory);
101103

102104
#nullable disable

projects/RabbitMQ.Client/client/impl/AutorecoveringChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public ValueTask BasicPublishAsync<TProperties>(string exchange, string routingK
288288
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
289289
=> InnerChannel.BasicPublishAsync(exchange, routingKey, basicProperties, body, mandatory, cancellationToken);
290290

291-
public ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey, TProperties basicProperties,
291+
public ValueTask BasicPublishAsync<TProperties>(ExchangeName exchange, RoutingKey routingKey, TProperties basicProperties,
292292
ReadOnlyMemory<byte> body, bool mandatory,
293293
CancellationToken cancellationToken)
294294
where TProperties : IReadOnlyBasicProperties, IAmqpHeader

projects/RabbitMQ.Client/client/impl/ChannelBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
11221122
}
11231123
}
11241124

1125-
public async ValueTask BasicPublishAsync<TProperties>(CachedString exchange, CachedString routingKey,
1125+
public async ValueTask BasicPublishAsync<TProperties>(ExchangeName exchange, RoutingKey routingKey,
11261126
TProperties basicProperties, ReadOnlyMemory<byte> body, bool mandatory,
11271127
CancellationToken cancellationToken)
11281128
where TProperties : IReadOnlyBasicProperties, IAmqpHeader
@@ -1143,11 +1143,11 @@ await _confirmSemaphore.WaitAsync(cancellationToken)
11431143

11441144
try
11451145
{
1146-
var cmd = new BasicPublishMemory(exchange.Bytes, routingKey.Bytes, mandatory, default);
1146+
var cmd = new BasicPublishMemory(exchange, routingKey, mandatory, default);
11471147

11481148
RabbitMQActivitySource.TryGetExistingContext(basicProperties, out ActivityContext existingContext);
11491149
using Activity sendActivity = RabbitMQActivitySource.PublisherHasListeners
1150-
? RabbitMQActivitySource.Send(routingKey.Value, exchange.Value, body.Length, existingContext)
1150+
? RabbitMQActivitySource.Send(routingKey, exchange, body.Length, existingContext)
11511151
: default;
11521152

11531153
if (sendActivity != null)

projects/Test/Integration/TestBasicPublish.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public async Task TestBasicRoundtripCachedString()
9090
_conn = await _connFactory.CreateConnectionAsync();
9191
_channel = await _conn.CreateChannelAsync();
9292

93-
CachedString exchangeName = new CachedString(string.Empty);
94-
CachedString queueName = new CachedString((await _channel.QueueDeclareAsync()).QueueName);
93+
var exchangeName = new ExchangeName(string.Empty);
94+
var queueName = new QueueName((await _channel.QueueDeclareAsync()).QueueName);
9595
byte[] sendBody = _encoding.GetBytes("hi");
9696
byte[] consumeBody = null;
9797
var consumer = new EventingBasicConsumer(_channel);
@@ -102,7 +102,7 @@ public async Task TestBasicRoundtripCachedString()
102102
consumeBody = a.Body.ToArray();
103103
consumerReceivedSemaphore.Release();
104104
};
105-
string tag = await _channel.BasicConsumeAsync(queueName.Value, true, consumer);
105+
string tag = await _channel.BasicConsumeAsync(queueName, true, consumer);
106106

107107
await _channel.BasicPublishAsync(exchangeName, queueName, sendBody);
108108
bool waitResFalse = await consumerReceivedSemaphore.WaitAsync(TimeSpan.FromSeconds(2));

projects/Test/Integration/TestFloodPublishing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public async Task TestUnthrottledFloodPublishing()
102102
}
103103
}
104104

105-
await _channel.BasicPublishAsync(CachedString.Empty, CachedString.Empty, _body);
105+
await _channel.BasicPublishAsync(ExchangeName.Empty, RoutingKey.Empty, _body);
106106
}
107107
}
108108
finally

projects/Test/Integration/TestPublishSharedChannelAsync.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ namespace Test.Integration
4040
public class TestPublishSharedChannelAsync : IntegrationFixture
4141
{
4242
private const string QueueName = "TestPublishSharedChannel_Queue";
43-
private static readonly CachedString ExchangeName = new CachedString("TestPublishSharedChannel_Ex");
44-
private static readonly CachedString PublishKey = new CachedString("TestPublishSharedChannel_RoutePub");
43+
private static readonly ExchangeName s_exchangeName = new ExchangeName("TestPublishSharedChannel_Ex");
44+
private static readonly RoutingKey s_publishKey = new RoutingKey("TestPublishSharedChannel_RoutePub");
4545
private const int Loops = 20;
4646
private const int Repeats = 1000;
4747

@@ -85,16 +85,16 @@ public async Task MultiThreadPublishOnSharedChannel()
8585
try
8686
{
8787
channel.ChannelShutdown += HandleChannelShutdown;
88-
await channel.ExchangeDeclareAsync(ExchangeName.Value, ExchangeType.Topic, passive: false, durable: false, autoDelete: true,
88+
await channel.ExchangeDeclareAsync(s_exchangeName, ExchangeType.Topic, passive: false, durable: false, autoDelete: true,
8989
noWait: false, arguments: null);
9090
await channel.QueueDeclareAsync(QueueName, exclusive: false, autoDelete: true);
91-
await channel.QueueBindAsync(QueueName, ExchangeName.Value, PublishKey.Value);
91+
await channel.QueueBindAsync(QueueName, s_exchangeName, s_publishKey);
9292

9393
for (int i = 0; i < Loops; i++)
9494
{
9595
for (int j = 0; j < Repeats; j++)
9696
{
97-
await channel.BasicPublishAsync(ExchangeName, PublishKey, _body, false);
97+
await channel.BasicPublishAsync(s_exchangeName, s_publishKey, _body, false);
9898
}
9999
}
100100
}

0 commit comments

Comments
 (0)