Skip to content

Commit b5b4f7b

Browse files
committed
Fixed DefaultTopic TopicBufferFullMode Mapping (#8393)
1 parent 4dce3e3 commit b5b4f7b

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

src/HotChocolate/Core/src/Subscriptions/DefaultTopic.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected DefaultTopic(
3838
Name = name ?? throw new ArgumentNullException(nameof(name));
3939
_channelOptions = new BoundedChannelOptions(capacity)
4040
{
41-
FullMode = (BoundedChannelFullMode) (int) fullMode,
41+
FullMode = fullMode.ToBoundedChannelFullMode()
4242
};
4343
_incoming = CreateUnbounded<TMessage>();
4444
_diagnosticEvents = diagnosticEvents;
@@ -54,7 +54,7 @@ protected DefaultTopic(
5454
Name = name ?? throw new ArgumentNullException(nameof(name));
5555
_channelOptions = new BoundedChannelOptions(capacity)
5656
{
57-
FullMode = (BoundedChannelFullMode) (int) fullMode,
57+
FullMode = fullMode.ToBoundedChannelFullMode()
5858
};
5959
_incoming = incomingMessages;
6060
_diagnosticEvents = diagnosticEvents;
@@ -108,7 +108,7 @@ public void Complete()
108108
}
109109

110110
/// <summary>
111-
/// Allows to subscribe to this topic. If the topic is already completed, this method will
111+
/// Allows subscribing to this topic. If the topic is already completed, this method will
112112
/// return null.
113113
/// </summary>
114114
/// <returns>
@@ -266,7 +266,8 @@ private void DispatchMessages()
266266

267267
if (!allWritesSuccessful || iterations++ >= 8)
268268
{
269-
// we will take a pause if we have dispatched 8 messages or if we could not dispatch all messages.
269+
// We will take a pause if we have dispatched 8 messages
270+
// or if we could not dispatch all messages.
270271
// This will give time for subscribers to unsubscribe and
271272
// others to hop on.
272273
break;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading.Channels;
2+
using HotChocolate.Subscriptions.Properties;
3+
4+
namespace HotChocolate.Subscriptions;
5+
6+
internal static class TopicBufferFullModeExtensions
7+
{
8+
public static BoundedChannelFullMode ToBoundedChannelFullMode(this TopicBufferFullMode fullMode)
9+
=> fullMode switch
10+
{
11+
TopicBufferFullMode.DropNewest => BoundedChannelFullMode.DropNewest,
12+
TopicBufferFullMode.DropOldest => BoundedChannelFullMode.DropOldest,
13+
TopicBufferFullMode.DropWrite => BoundedChannelFullMode.DropWrite,
14+
_ => throw new ArgumentOutOfRangeException(
15+
nameof(fullMode),
16+
fullMode,
17+
Resources.ConvertFullMode_Value_NotSupported)
18+
};
19+
}

src/HotChocolate/Core/src/Subscriptions/ITopic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public interface ITopic : IDisposable
1111
public Type MessageType { get; }
1212

1313
/// <summary>
14-
/// Allows to complete a topic.
14+
/// Allows completing a topic.
1515
/// </summary>
1616
void Complete();
1717
}

src/HotChocolate/Core/src/Subscriptions/Properties/Resources.Designer.cs

Lines changed: 19 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/HotChocolate/Core/src/Subscriptions/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,7 @@
113113
<data name="InvalidMessageTypeException_Message" xml:space="preserve">
114114
<value>The topic already exists with a different message type. Topic message type: {0}. Requested message type: {1}.</value>
115115
</data>
116+
<data name="TopicBufferFullModeExtensions_ConvertFullMode_The_specified_topic_buffer_full_mode_is_not_supported_" xml:space="preserve">
117+
<value>The specified topic buffer full mode is not supported.</value>
118+
</data>
116119
</root>

0 commit comments

Comments
 (0)