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
Show file tree
Hide file tree
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
29 changes: 26 additions & 3 deletions src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public sealed class AzureStorageOrchestrationService :
IOrchestrationService,
IOrchestrationServiceClient,
IDisposable,
IOrchestrationServiceQueryClient
IOrchestrationServiceQueryClient,
IOrchestrationServicePurgeClient
{
static readonly HistoryEvent[] EmptyHistoryEventList = new HistoryEvent[0];

Expand Down Expand Up @@ -1771,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<PurgeHistoryResult> PurgeInstanceHistoryAsync(string instanceId)
public Task<Core.PurgeHistoryResult> PurgeInstanceHistoryAsync(string instanceId)
{
return this.trackingStore.PurgeInstanceHistoryAsync(instanceId);
}
Expand All @@ -1783,11 +1784,33 @@ public Task<PurgeHistoryResult> PurgeInstanceHistoryAsync(string instanceId)
/// <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<PurgeHistoryResult> PurgeInstanceHistoryAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
public Task<Core.PurgeHistoryResult> PurgeInstanceHistoryAsync(DateTime createdTimeFrom, DateTime? createdTimeTo, IEnumerable<OrchestrationStatus> runtimeStatus)
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
{
return this.trackingStore.PurgeInstanceHistoryAsync(createdTimeFrom, createdTimeTo, runtimeStatus);
}

/// <summary>
/// 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)
{
return this.PurgeInstanceHistoryAsync(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>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)
{
return this.PurgeInstanceHistoryAsync(createdTimeFrom, createdTimeTo, runtimeStatus);
}

/// <summary>
/// Wait for an orchestration to reach any terminal state within the given timeout
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/DurableTask.AzureStorage/PurgeHistoryResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

namespace DurableTask.AzureStorage
{
using System;
/// <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)]
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
public class PurgeHistoryResult
{
/// <summary>
Expand Down
43 changes: 43 additions & 0 deletions src/DurableTask.Core/IOrchestrationServicePurgeClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ----------------------------------------------------------------------------------
// 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;
using System.Threading.Tasks;

/// <summary>
/// Orchestration Service interface for purging instance history
/// </summary>
public interface IOrchestrationServicePurgeClient
{
// Purge instance history operations

/// <summary>
/// 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>
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
Task<PurgeHistoryResult> 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);
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved
}
}
49 changes: 49 additions & 0 deletions src/DurableTask.Core/PurgeHistoryResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ----------------------------------------------------------------------------------
// 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
{
/// <summary>
/// Class to hold statistics about this execution of purge history
/// </summary>
public class PurgeHistoryResult
{
/// <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)
{
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; }
shreyas-gopalakrishna marked this conversation as resolved.
Show resolved Hide resolved

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