1010
1111namespace Cysharp . Runtime . Multicast . Distributed . Nats ;
1212
13+ /// <summary>
14+ /// Provides functionality for managing multicast groups over a NATS (NATS.io) connection.
15+ /// </summary>
1316public class NatsGroupProvider : IMulticastGroupProvider
1417{
1518 private readonly ConcurrentDictionary < ( string Name , Type KeyType , Type ReceiverType ) , object > _groups = new ( ) ;
@@ -18,10 +21,16 @@ public class NatsGroupProvider : IMulticastGroupProvider
1821 private readonly IRemoteSerializer _serializer ;
1922 private readonly MessagePackSerializerOptions _messagePackSerializerOptionsForKey ;
2023
24+ /// <summary>
25+ /// Initializes a new instance of the <see cref="NatsGroupProvider"/> class with the specified proxy factory, serializer, and configuration options.
26+ /// </summary>
2127 public NatsGroupProvider ( IRemoteProxyFactory proxyFactory , IRemoteSerializer serializer , IOptions < NatsGroupOptions > options )
2228 : this ( proxyFactory , serializer , options . Value )
2329 { }
2430
31+ /// <summary>
32+ /// Initializes a new instance of the <see cref="NatsGroupProvider"/> class, which provides functionality for managing groups using NATS messaging.
33+ /// </summary>
2534 public NatsGroupProvider ( IRemoteProxyFactory proxyFactory , IRemoteSerializer serializer , NatsGroupOptions options )
2635 {
2736 _connection = new NatsConnection ( NatsOpts . Default with { Url = options . Url } ) ;
@@ -34,10 +43,12 @@ public NatsGroupProvider(IRemoteProxyFactory proxyFactory, IRemoteSerializer ser
3443 ) ;
3544 }
3645
46+ /// <inheritdoc />
3747 public IMulticastAsyncGroup < TKey , TReceiver > GetOrAddGroup < TKey , TReceiver > ( string name )
3848 where TKey : IEquatable < TKey >
3949 => ( IMulticastAsyncGroup < TKey , TReceiver > ) _groups . GetOrAdd ( ( name , typeof ( TKey ) , typeof ( TReceiver ) ) , _ => new NatsGroup < TKey , TReceiver > ( name , _connection , _proxyFactory , _serializer , _messagePackSerializerOptionsForKey , Remove ) ) ;
4050
51+ /// <inheritdoc />
4152 public IMulticastSyncGroup < TKey , TReceiver > GetOrAddSynchronousGroup < TKey , TReceiver > ( string name )
4253 where TKey : IEquatable < TKey >
4354 => ( IMulticastSyncGroup < TKey , TReceiver > ) _groups . GetOrAdd ( ( name , typeof ( TKey ) , typeof ( TReceiver ) ) , _ => new NatsGroup < TKey , TReceiver > ( name , _connection , _proxyFactory , _serializer , _messagePackSerializerOptionsForKey , Remove ) ) ;
@@ -49,6 +60,9 @@ private void Remove<TKey, TReceiver>(NatsGroup<TKey, TReceiver> group)
4960 }
5061}
5162
63+ /// <summary>
64+ /// Represents configuration options for a NATS group, including server connection details and serialization settings.
65+ /// </summary>
5266public class NatsGroupOptions
5367{
5468 /// <summary>
@@ -60,4 +74,4 @@ public class NatsGroupOptions
6074 /// Gets or sets a MessagePackSerializerOptions used for serializing the key.
6175 /// </summary>
6276 public MessagePackSerializerOptions MessagePackSerializerOptionsForKey { get ; set ; } = MessagePackSerializer . DefaultOptions ;
63- }
77+ }
0 commit comments