fix: seal and adjust async usage
This commit is contained in:
parent
7df83c9877
commit
2ec47ae884
1 changed files with 3 additions and 4 deletions
|
@ -10,7 +10,7 @@ using Wonderking.Packets;
|
|||
namespace Continuity.AuthServer.Consumers;
|
||||
|
||||
[UsedImplicitly]
|
||||
public class PacketConsumer : IConsumer<RawPacket>, IDisposable
|
||||
public sealed class PacketConsumer : IConsumer<RawPacket>, IDisposable
|
||||
{
|
||||
private readonly ActivitySource _activitySource;
|
||||
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
|
||||
|
@ -21,20 +21,19 @@ public class PacketConsumer : IConsumer<RawPacket>, IDisposable
|
|||
_activitySource = new ActivitySource(nameof(PacketConsumer));
|
||||
}
|
||||
|
||||
public Task Consume(ConsumeContext<RawPacket> context)
|
||||
public async Task Consume(ConsumeContext<RawPacket> context)
|
||||
{
|
||||
using var activity = _activitySource?.StartActivity("PacketConsumption");
|
||||
activity?.SetTag("PacketId", context.Message.OperationCode.ToString());
|
||||
activity?.SetTag("SessionId", context.Message.Session.Id.ToString());
|
||||
activity?.SetTag("PacketSize", context.Message.MessageBody.Length);
|
||||
|
||||
return _distributorService.AddPacketAsync(context.Message.MessageBody, context.Message.OperationCode,
|
||||
await _distributorService.AddPacketAsync(context.Message.MessageBody, context.Message.OperationCode,
|
||||
context.Message.Session);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_activitySource.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue