Skip to content

Commit

Permalink
used ChannelWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
granstel committed Mar 27, 2024
1 parent 8c3ffed commit 1fd4c1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Dodo1000Bot.Services/UsersService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Dodo1000Bot.Models;
using Dodo1000Bot.Models.Domain;
Expand All @@ -16,16 +17,16 @@ public class UsersService : IUsersService
{
private readonly ILogger<UsersService> _log;
private readonly IUsersRepository _usersRepository;
private readonly INotificationsService _notificationsService;
private readonly ChannelWriter<Notification> _notificationsChannel;

public UsersService(
ILogger<UsersService> log,
IUsersRepository usersRepository,
INotificationsService notificationsService)
ChannelWriter<Notification> notificationsChannel)
{
_log = log;
_usersRepository = usersRepository;
_notificationsService = notificationsService;
_notificationsChannel = notificationsChannel;
}

public async Task SaveAndNotify(User user, CancellationToken cancellationToken)
Expand Down Expand Up @@ -54,7 +55,7 @@ internal async Task CheckAndNotifyAboutSubscribers(CancellationToken cancellatio
}
};

await _notificationsService.Save(notification, cancellationToken);
await _notificationsChannel.WriteAsync(notification, cancellationToken);
}
catch (Exception e)
{
Expand Down

0 comments on commit 1fd4c1f

Please sign in to comment.