Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purge instance history support #704

Merged
merged 4 commits into from
Apr 15, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed Core/PurgeHistoryResult to Core/PurgeResult.cs to remove ambi…
…guity
shreyas-gopalakrishna committed Apr 14, 2022
commit 02bd5575f28dfd58b09f3161c812f6769ca88944
22 changes: 11 additions & 11 deletions src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs
Original file line number Diff line number Diff line change
@@ -1772,7 +1772,7 @@ public async Task<string> GetOrchestrationHistoryAsync(string instanceId, string
/// </summary>
/// <param name="instanceId">Instance ID of the orchestration.</param>
/// <returns>Class containing number of storage requests sent, along with instances and rows deleted/purged</returns>
public Task<Core.PurgeHistoryResult> PurgeInstanceHistoryAsync(string instanceId)
public Task<PurgeHistoryResult> PurgeInstanceHistoryAsync(string instanceId)
{
return this.trackingStore.PurgeInstanceHistoryAsync(instanceId);
}
@@ -1784,7 +1784,7 @@ public async Task<string> GetOrchestrationHistoryAsync(string instanceId, string
/// <param name="createdTimeTo">CreatedTime of orchestrations. Purges history less than this value.</param>
/// <param name="runtimeStatus">RuntimeStatus of orchestrations. You can specify several status.</param>
/// <returns>Class containing number of storage requests sent, along with instances and rows deleted/purged</returns>
public Task<Core.PurgeHistoryResult> PurgeInstanceHistoryAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
public Task<PurgeHistoryResult> PurgeInstanceHistoryAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
{
return this.trackingStore.PurgeInstanceHistoryAsync(createdTimeFrom, createdTimeTo, runtimeStatus);
}
@@ -1793,22 +1793,22 @@ public async Task<string> GetOrchestrationHistoryAsync(string instanceId, string
/// Purge history for an orchestration with a specified instance id.
/// </summary>
/// <param name="instanceId">Instance ID of the orchestration.</param>
/// <returns>Class containing number of storage requests sent, along with instances and rows deleted/purged</returns>
public Task<Core.PurgeHistoryResult> PurgeInstanceStateAsync(string instanceId)
/// <returns><see cref="PurgeResult"/> object containing more information about the purged instance.</returns>
async Task<PurgeResult> IOrchestrationServicePurgeClient.PurgeInstanceStateAsync(string instanceId)
{
return this.PurgeInstanceHistoryAsync(instanceId);
PurgeHistoryResult storagePurgeHistoryResult = await this.PurgeInstanceHistoryAsync(instanceId);
return storagePurgeHistoryResult.ToCorePurgeHistoryResult();
}

/// <summary>
/// Purge history for orchestrations that match the specified parameters.
/// </summary>
/// <param name="createdTimeFrom">CreatedTime of orchestrations. Purges history grater than this value.</param>
/// <param name="createdTimeTo">CreatedTime of orchestrations. Purges history less than this value.</param>
/// <param name="runtimeStatus">RuntimeStatus of orchestrations. You can specify several status.</param>
/// <returns>Class containing number of storage requests sent, along with instances and rows deleted/purged</returns>
public Task<Core.PurgeHistoryResult> PurgeInstanceStateAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
/// <param name="purgeInstanceCondition"><see cref="PurgeInstanceCondition"/>Conditions that should match to purge orchestration history.</param>
/// <returns><see cref="PurgeResult"/> object containing more information about the purged instance.</returns>
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
async Task<PurgeResult> IOrchestrationServicePurgeClient.PurgeInstanceStateAsync(PurgeInstanceCondition purgeInstanceCondition)
{
return this.PurgeInstanceHistoryAsync(createdTimeFrom, createdTimeTo, runtimeStatus);
PurgeHistoryResult storagePurgeHistoryResult = await this.PurgeInstanceHistoryAsync(purgeInstanceCondition.CreatedTimeFrom, purgeInstanceCondition.CreatedTimeTo, purgeInstanceCondition.RuntimeStatus);
return storagePurgeHistoryResult.ToCorePurgeHistoryResult();
}

/// <summary>
12 changes: 10 additions & 2 deletions src/DurableTask.AzureStorage/PurgeHistoryResult.cs
Original file line number Diff line number Diff line change
@@ -13,11 +13,11 @@

namespace DurableTask.AzureStorage
{
using System;
using DurableTask.Core;

/// <summary>
/// Class to hold statistics about this execution of purge history
/// </summary>
[Obsolete("Not used any more. Will use DurableTask.Core.PurgeHistoryResult going forward.", true)]
public class PurgeHistoryResult
{
/// <summary>
@@ -47,5 +47,13 @@ public PurgeHistoryResult(int storageRequests, int instancesDeleted, int rowsDel
/// Number of rows deleted during this execution of purge history
/// </summary>
public int RowsDeleted { get; }

/// <summary>
/// Converts from AzureStorage.PurgeHistoryResult to Core.PurgeResult type
/// </summary>
public PurgeResult ToCorePurgeHistoryResult()
{
return new PurgeResult(this.InstancesDeleted);
}
}
}
14 changes: 5 additions & 9 deletions src/DurableTask.Core/IOrchestrationServicePurgeClient.cs
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@

namespace DurableTask.Core
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

/// <summary>
@@ -28,16 +26,14 @@ public interface IOrchestrationServicePurgeClient
/// Purge history for an orchestration with a specified instance id.
/// </summary>
/// <param name="instanceId">Instance ID of the orchestration.</param>
/// <returns><see cref="PurgeHistoryResult"/> object containing number of storage requests sent, along with instances and rows deleted/purged.</returns>
Task<PurgeHistoryResult> PurgeInstanceStateAsync(string instanceId);
/// <returns><see cref="PurgeResult"/> object containing more information about the purged instance.</returns>
Task<PurgeResult> PurgeInstanceStateAsync(string instanceId);

/// <summary>
/// Purge history for orchestrations that match the specified parameters.
/// </summary>
/// <param name="createdTimeFrom">CreatedTime of orchestrations. Purges history grater than this value.</param>
/// <param name="createdTimeTo">CreatedTime of orchestrations. Purges history less than this value.</param>
/// <param name="runtimeStatus">RuntimeStatus of orchestrations. You can specify several status.</param>
/// <returns><see cref="PurgeHistoryResult"/> object containing number of storage requests sent, along with instances and rows deleted/purged.</returns>
Task<PurgeHistoryResult> PurgeInstanceStateAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus);
/// <param name="purgeInstanceCondition"><see cref="PurgeInstanceCondition"/>Conditions that should match to purge orchestration history.</param>
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
/// <returns><see cref="PurgeResult"/> object containing more information about the purged instance.</returns>
Task<PurgeResult> PurgeInstanceStateAsync(PurgeInstanceCondition purgeInstanceCondition);
}
}
53 changes: 53 additions & 0 deletions src/DurableTask.Core/PurgeInstanceCondition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace DurableTask.Core
{
using System;
using System.Collections.Generic;

/// <summary>
/// Class to hold conditions that should match to purge orchestration history
/// </summary>
public class PurgeInstanceCondition
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
{
/// <summary>
/// Constructor for purge instance conditions
/// </summary>
/// <param name="createdTimeFrom">CreatedTime of orchestrations. Purges history grater than this value.</param>
/// <param name="createdTimeTo">CreatedTime of orchestrations. Purges history less than this value.</param>
/// <param name="runtimeStatus">RuntimeStatus of orchestrations. You can specify several status.</param>
public PurgeInstanceCondition(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
{
this.CreatedTimeFrom = createdTimeFrom;
this.CreatedTimeTo = createdTimeTo;
this.RuntimeStatus = runtimeStatus;
}

/// <summary>
/// CreatedTime of orchestrations. Purges history grater than this value.
/// </summary>
public DateTime CreatedTimeFrom { get; set; }

/// <summary>
/// CreatedTime of orchestrations. Purges history less than this value.
/// </summary>
public DateTime? CreatedTimeTo { get; set; }

/// <summary>
/// RuntimeStatus of orchestrations
/// </summary>
public IEnumerable<OrchestrationStatus> RuntimeStatus { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -16,34 +16,20 @@ namespace DurableTask.Core
/// <summary>
/// Class to hold statistics about this execution of purge history
/// </summary>
public class PurgeHistoryResult
public class PurgeResult
{
/// <summary>
/// Constructor for purge history statistics
/// </summary>
/// <param name="storageRequests">Requests sent to storage</param>
/// <param name="instancesDeleted">Number of instances deleted</param>
/// <param name="rowsDeleted">Number of rows deleted</param>
public PurgeHistoryResult(int storageRequests, int instancesDeleted, int rowsDeleted)
public PurgeResult(int instancesDeleted)
{
this.StorageRequests = storageRequests;
this.InstancesDeleted = instancesDeleted;
this.RowsDeleted = rowsDeleted;
}

/// <summary>
/// Number of requests sent to Storage during this execution of purge history
/// </summary>
public int StorageRequests { get; }

/// <summary>
/// Number of instances deleted during this execution of purge history
/// </summary>
public int InstancesDeleted { get; }

/// <summary>
/// Number of rows deleted during this execution of purge history
/// </summary>
public int RowsDeleted { get; }
}
}