public async Task DeleteMembershipTableEntries(string clusterId) { try { var keys = new Dictionary<string, AttributeValue> { { $":{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", new AttributeValue(clusterId) } }; var records = await storage.QueryAsync(TABLE_NAME_DEFAULT_VALUE, keys, $"{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME} = :{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", item => new SiloInstanceRecord(item)); var toDelete = new List<Dictionary<string, AttributeValue>>(); foreach (var record in records) { toDelete.Add(record.GetKeys()); } List<Task> tasks = new List<Task>(); foreach (var batch in toDelete.BatchIEnumerable(MAX_BATCH_SIZE)) { tasks.Add(storage.DeleteEntriesAsync(TABLE_NAME_DEFAULT_VALUE, batch)); } await Task.WhenAll(tasks); } catch (Exception exc) { logger.Error(ErrorCode.MembershipBase, string.Format("Unable to delete membership records on table {0} for clusterId {1}: Exception={2}", TABLE_NAME_DEFAULT_VALUE, clusterId, exc)); throw; } }
public async Task DeleteMembershipTableEntries(string clusterId) { try { var keys = new Dictionary <string, AttributeValue> { { $":{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", new AttributeValue(clusterId) } }; var records = await storage.QueryAsync(this.options.TableName, keys, $"{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME} = :{SiloInstanceRecord.DEPLOYMENT_ID_PROPERTY_NAME}", item => new SiloInstanceRecord(item)); var toDelete = new List <Dictionary <string, AttributeValue> >(); foreach (var record in records.results) { toDelete.Add(record.GetKeys()); } List <Task> tasks = new List <Task>(); foreach (var batch in toDelete.BatchIEnumerable(MAX_BATCH_SIZE)) { tasks.Add(storage.DeleteEntriesAsync(this.options.TableName, batch)); } await Task.WhenAll(tasks); } catch (Exception exc) { this.logger.LogError( (int)ErrorCode.MembershipBase, exc, "Unable to delete membership records on table {TableName} for ClusterId {ClusterId}", this.options.TableName, clusterId); throw; } }