Beispiel #1
0
        public async Task StartAsync(CancellationToken ct = default)
        {
            await _subscriber.SubscribeAsync <TodoListQuery>(OnListQuery, ct);

            await _subscriber.SubscribeAsync <TodoCreated>(OnTodoCreated, ct);

            await _subscriber.SubscribeAsync <TodoDeleted>(OnTodoDeleted, ct);
        }
Beispiel #2
0
 public static Task SubscribeAsync(this IMessageSubscriber subscriber, Action <IMessage> handler, CancellationToken cancellationToken = default)
 {
     return(subscriber.SubscribeAsync((msg, token) => {
         handler(msg);
         return Task.CompletedTask;
     }, cancellationToken));
 }
Beispiel #3
0
 public static Task SubscribeAsync <TMessage>(
     this IMessageSubscriber subscriber,
     Func <TMessage, CancellationToken, Task> handlerFunc,
     CancellationToken token = default)
 {
     return(subscriber.SubscribeAsync(new AnnonymousMessageHandler <TMessage>(handlerFunc), token));
 }
Beispiel #4
0
 public static Task SubscribeAsync <T>(this IMessageSubscriber subscriber, Action <T> handler, CancellationToken cancellationToken = default(CancellationToken)) where T : class
 {
     return(subscriber.SubscribeAsync <T>((msg, token) => {
         handler(msg);
         return Task.CompletedTask;
     }, cancellationToken));
 }
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     await _subscriber.SubscribeAsync <ClientMessage>(async (message, ct) =>
     {
         var clients = message.ClientIds.Any()
   ? _hubContext.Clients.Clients(message.ClientIds)
   : _hubContext.Clients.All;
         await clients.SendAsync("dataReceived", message, ct);
     }, cancellationToken);
 }
 public Task RunAsync(CancellationToken token)
 {
     return(_subscriber.SubscribeAsync <PlanOverage>(async overage => {
         _logger.Info("Enqueueing plan overage work item for organization: {0} IsOverHourlyLimit: {1} IsOverMonthlyLimit: {2}", overage.OrganizationId, overage.IsHourly, !overage.IsHourly);
         await _workItemQueue.EnqueueAsync(new OrganizationNotificationWorkItem {
             OrganizationId = overage.OrganizationId,
             IsOverHourlyLimit = overage.IsHourly,
             IsOverMonthlyLimit = !overage.IsHourly
         }).AnyContext();
     }, token));
 }
        public Task RunAsync(CancellationToken token)
        {
            return(_subscriber.SubscribeAsync <PlanOverage>(overage => {
                _logger.LogInformation("Enqueueing plan overage work item for organization: {OrganizationId} IsOverHourlyLimit: {IsOverHourlyLimit} IsOverMonthlyLimit: {IsOverMonthlyLimit}", overage.OrganizationId, overage.IsHourly, !overage.IsHourly);

                return _workItemQueue.EnqueueAsync(new OrganizationNotificationWorkItem {
                    OrganizationId = overage.OrganizationId,
                    IsOverHourlyLimit = overage.IsHourly,
                    IsOverMonthlyLimit = !overage.IsHourly
                });
            }, token));
        }
        public async Task StartAsync(CancellationToken token)
        {
            _logger.Debug("Subscribing to message bus notifications");
            await _subscriber.SubscribeAsync <ExtendedEntityChanged>(OnEntityChangedAsync, token);

            await _subscriber.SubscribeAsync <PlanChanged>(OnPlanChangedAsync, token);

            await _subscriber.SubscribeAsync <PlanOverage>(OnPlanOverageAsync, token);

            await _subscriber.SubscribeAsync <UserMembershipChanged>(OnUserMembershipChangedAsync, token);

            await _subscriber.SubscribeAsync <ReleaseNotification>(OnReleaseNotificationAsync, token);

            await _subscriber.SubscribeAsync <SystemNotification>(OnSystemNotificationAsync, token);

            _logger.Debug("Subscribed to message bus notifications");
        }
    public async Task RunAsync(CancellationToken shutdownToken = default)
    {
        if (!_options.EnableWebSockets)
        {
            return;
        }

        _logger.LogDebug("Subscribing to message bus notifications");
        await Task.WhenAll(
            _subscriber.SubscribeAsync <EntityChanged>(OnEntityChangedAsync, shutdownToken),
            _subscriber.SubscribeAsync <PlanChanged>(OnPlanChangedAsync, shutdownToken),
            _subscriber.SubscribeAsync <PlanOverage>(OnPlanOverageAsync, shutdownToken),
            _subscriber.SubscribeAsync <UserMembershipChanged>(OnUserMembershipChangedAsync, shutdownToken),
            _subscriber.SubscribeAsync <ReleaseNotification>(OnReleaseNotificationAsync, shutdownToken),
            _subscriber.SubscribeAsync <SystemNotification>(OnSystemNotificationAsync, shutdownToken)
            );

        _logger.LogDebug("Subscribed to message bus notifications");
    }
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     await _subscriber.SubscribeAsync <FakeEvent>(HandleAsync, cancellationToken).ConfigureAwait(false);
 }
Beispiel #11
0
        public async Task StartAsync(CancellationToken ct = default)
        {
            await _subscriber.SubscribeAsync <CreateTodo>(OnCreateTodo, ct);

            await _subscriber.SubscribeAsync <DeleteTodo>(OnDeleteTodo, ct);
        }
Beispiel #12
0
 public static Task SubscribeAsync(this IMessageSubscriber subscriber, Func <IMessage, Task> handler, CancellationToken cancellationToken = default)
 {
     return(subscriber.SubscribeAsync((msg, token) => handler(msg), cancellationToken));
 }
Beispiel #13
0
 public static Task SubscribeAsync <T>(this IMessageSubscriber subscriber, Func <T, Task> handler, CancellationToken cancellationToken = default) where T : class
 {
     return(subscriber.SubscribeAsync <T>((msg, token) => handler(msg), cancellationToken));
 }
Beispiel #14
0
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     await _subscriber.SubscribeAsync <NotificationMessage>(HandleAsync, cancellationToken : cancellationToken).ConfigureAwait(false);
 }