/// <summary>
 /// Initializes a new instance of the <see cref="CloudTableBackgroundCommandEventRepository"/> class.
 /// </summary>
 /// <param name="cloudTable">The <see cref="CloudTable"/>.</param>
 /// <param name="commandSerializer">The <see cref="IBackgroundCommandSerializer"/>.</param>
 public CloudTableBackgroundCommandEventRepository(
     CloudTable cloudTable,
     IBackgroundCommandSerializer commandSerializer)
 {
     _cloudTable        = cloudTable ?? throw new ArgumentNullException(nameof(cloudTable));
     _commandSerializer = commandSerializer;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AzureFunctionsQueueStorageHandler"/> class.
 /// </summary>
 /// <param name="serializer">The <see cref="IBackgroundCommandSerializer"/>.</param>
 /// <param name="processor">The <see cref="IBackgroundProcessor"/> to use.</param>
 public AzureFunctionsQueueStorageHandler(
     IBackgroundCommandSerializer serializer,
     IBackgroundProcessor processor)
 {
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _processor  = processor ?? throw new ArgumentNullException(nameof(processor));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudQueueBackgroundDispatcher"/> class.
 /// </summary>
 /// <param name="options">The <see cref="CloudQueueBackgroundDispatcherOptions"/>.</param>
 /// <param name="queue">The <see cref="CloudQueue"/>.</param>
 /// <param name="serializer">The <see cref="IBackgroundCommandSerializer"/>.</param>
 public CloudQueueBackgroundDispatcher(
     IOptions <CloudQueueBackgroundDispatcherOptions> options,
     CloudQueue queue,
     IBackgroundCommandSerializer serializer)
 {
     _options    = options ?? throw new ArgumentNullException(nameof(options));
     _queue      = queue ?? throw new ArgumentNullException(nameof(queue));
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DistributedCacheBackgroundCommandEventRepository"/> class.
 /// </summary>
 /// <param name="cache">The <see cref="IDistributedCache"/>.</param>
 /// <param name="expiration">The duration of items in the cache before expiring.</param>
 /// <param name="serializer">The <see cref="IBackgroundCommandSerializer"/>.</param>
 public DistributedCacheBackgroundCommandEventRepository(
     IDistributedCache cache,
     TimeSpan expiration,
     IBackgroundCommandSerializer serializer)
 {
     _cache      = cache ?? throw new ArgumentNullException(nameof(cache));
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _distributedCacheEntryOptions = new DistributedCacheEntryOptions {
         SlidingExpiration = expiration
     };
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudQueueBackgroundService"/> class.
 /// </summary>
 /// <param name="options">The <see cref="CloudQueueBackgroundServiceOptions"/>.</param>
 /// <param name="queue">The <see cref="CloudQueue"/>.</param>
 /// <param name="serializer">The <see cref="IBackgroundCommandSerializer"/>.</param>
 /// <param name="services">The <see cref="IServiceProvider"/> used to manage scopes.</param>
 /// <param name="logger">The <see cref="ILogger"/>.</param>
 public CloudQueueBackgroundService(
     IOptions <CloudQueueBackgroundServiceOptions> options,
     CloudQueue queue,
     IBackgroundCommandSerializer serializer,
     IServiceProvider services,
     ILogger <CloudQueueBackgroundService> logger)
 {
     _options    = options ?? throw new ArgumentNullException(nameof(options));
     _queue      = queue ?? throw new ArgumentNullException(nameof(queue));
     _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
     _services   = services ?? throw new ArgumentNullException(nameof(services));
     _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #6
0
 public EventCacheEntry(BackgroundCommandEvent commandEvent, IBackgroundCommandSerializer serializer)
 {
     EventStatus    = commandEvent.Status.ToString();
     EventTimestamp = commandEvent.Timestamp;
     Command        = serializer.SerializeAsync(commandEvent.Command).Result;
     if (commandEvent.Exception != null)
     {
         try
         {
             Exception = JsonConvert.SerializeObject(commandEvent.Exception);
         }
         catch (Exception ex)
         {
             Exception = ex.ToString();
         }
     }
 }
 public EventTableEntity(BackgroundCommandEvent commandEvent, IBackgroundCommandSerializer serializer)
 {
     PartitionKey   = commandEvent.Command.Id;
     RowKey         = BackgroundCommandIdGenerator.Generate();
     EventStatus    = commandEvent.Status.ToString();
     EventTimestamp = commandEvent.Timestamp;
     Command        = serializer.SerializeAsync(commandEvent.Command).Result;
     if (commandEvent.Exception != null)
     {
         try
         {
             Exception = JsonConvert.SerializeObject(commandEvent.Exception);
         }
         catch (Exception ex)
         {
             Exception = ex.ToString();
         }
     }
 }
            public BackgroundCommandEvent ToBackgroundCommandEvent(IBackgroundCommandSerializer serializer)
            {
                var status = BackgroundCommandEventStatus.Unknown;

                if (Enum.TryParse <BackgroundCommandEventStatus>(EventStatus, out var parsedStatus))
                {
                    status = parsedStatus;
                }

                Exception commandException = null;

                try
                {
                    if (!string.IsNullOrEmpty(Exception))
                    {
                        commandException = JsonConvert.DeserializeObject <Exception>(Exception);
                    }
                }
                catch
                {
                }

                return(new BackgroundCommandEvent(serializer.DeserializeAsync(Command).Result, status, EventTimestamp, commandException));
            }