예제 #1
0
        internal static async Task StartSearchSync(IDurableOrchestrationClient starter,
                                                   ILogger log, SyncType syncType)

        {
            var model            = new SearchSyncInput(syncType);
            var existingInstance = await starter.GetStatusAsync(model.InstanceId);

            if (existingInstance == null)
            {
                log.LogInformation($"start new instance of {syncType}");
                await starter.StartNewAsync(SearchSyncName, model.InstanceId, model);

                return;
            }
            if (existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Failed)
            {
                log.LogInformation($"terminate existing instance");
                await starter.TerminateAsync(model.InstanceId, "the status failed");
            }

            if (existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Running)
            {
                if (existingInstance.LastUpdatedTime < DateTime.UtcNow.AddHours(-1))
                {
                    log.LogError($"issue with {syncType}");
                    await starter.TerminateAsync(model.InstanceId, $"issue with {syncType}");
                }
                else
                {
                    log.LogInformation($"{model.InstanceId} is in status {existingInstance.RuntimeStatus}");
                    return;
                }
            }
            await starter.StartNewAsync(SearchSyncName, model.InstanceId, model);
        }
예제 #2
0
        public static async Task SetSyncProgress(
            [ActivityTrigger] SearchSyncInput searchSyncInput, IBinder binder, CancellationToken token)
        {
            var dynamicBlobAttribute =
                new BlobAttribute($"spitball/AzureSearch/{searchSyncInput.BlobName}-version.txt");

            var blob = await binder.BindAsync <CloudBlockBlob>(dynamicBlobAttribute, token);

            await blob.UploadTextAsync(searchSyncInput.SyncAzureQuery.ToString());
        }
예제 #3
0
 public static async Task <SyncResponse> DoSearchSync(
     [ActivityTrigger] SearchSyncInput input,
     [Inject] ILifetimeScope lifetimeScope,
     IBinder binder,
     ILogger log,
     CancellationToken token)
 {
     log.LogInformation($"Going to sync {input}");
     using (var child = lifetimeScope.BeginLifetimeScope())
     {
         var syncObject = child.ResolveKeyed <IDbToSearchSync>(input.SyncType);
         return(await syncObject.DoSyncAsync(input.SyncAzureQuery, binder, token));
     }
 }