public Task ProcessAsync(JToken argumentToken)
            {
                var args = argumentToken.ToObject <Arguments>();
                ISubscriptionActor actor = _factory.Lookup(new ActorId(args.Subscriptionid));

                return(actor.RunActionAsync(args.Method, args.MethodArguments));
            }
示例#2
0
 private async Task UpdateSubscriptionsForMergedPRAsync(
     IEnumerable <SubscriptionPullRequestUpdate> subscriptionPullRequestUpdates)
 {
     foreach (SubscriptionPullRequestUpdate update in subscriptionPullRequestUpdates)
     {
         ISubscriptionActor actor = SubscriptionActorFactory(new ActorId(update.SubscriptionId));
         await actor.UpdateForMergedPullRequestAsync(update.BuildId);
     }
 }
示例#3
0
 private async Task UpdateSubscriptionAsync(Guid subscriptionId, int buildId)
 {
     using (Logger.BeginScope(
                "Updating subscription '{subscriptionId}' with build '{buildId}'",
                subscriptionId,
                buildId))
     {
         ISubscriptionActor actor = SubscriptionActorFactory(new ActorId(subscriptionId));
         await actor.UpdateAsync(buildId);
     }
 }
 private async Task UpdateSubscriptionAsync(Guid subscriptionId, int buildId)
 {
     using (Logger.BeginScope(
                "Updating subscription '{subscriptionId}' with build '{buildId}'",
                subscriptionId,
                buildId))
     {
         try
         {
             ISubscriptionActor actor = SubscriptionActorFactory.Lookup(new ActorId(subscriptionId));
             await actor.UpdateAsync(buildId);
         }
         catch (Exception e)
         {
             Logger.LogError(e, $"Failed to update subscription '{subscriptionId}' with build '{buildId}'");
         }
     }
 }
示例#5
0
        public virtual async Task <IActionResult> RetrySubscriptionActionAsync(Guid id, long timestamp)
        {
            DateTime ts = DateTimeOffset.FromUnixTimeSeconds(timestamp).UtcDateTime;

            Data.Models.Subscription subscription = await _context.Subscriptions.Where(sub => sub.Id == id)
                                                    .FirstOrDefaultAsync();

            if (subscription == null)
            {
                return(NotFound());
            }

            SubscriptionUpdateHistoryEntry update = await _context.SubscriptionUpdateHistory
                                                    .Where(u => u.SubscriptionId == id)
                                                    .FirstOrDefaultAsync(u => Math.Abs(EF.Functions.DateDiffSecond(u.Timestamp, ts)) < 1);

            if (update == null)
            {
                return(NotFound());
            }

            if (update.Success)
            {
                return(StatusCode(
                           (int)HttpStatusCode.NotAcceptable,
                           new ApiError("That action was successful, it cannot be retried.")));
            }

            _queue.Post(
                async() =>
            {
                ISubscriptionActor actor = _subscriptionActorFactory(new ActorId(subscription.Id));
                await actor.RunActionAsync(update.Method, update.Arguments);
            });

            return(Accepted());
        }