WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 31 additions & 0 deletions core/rust/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,37 @@ pub unsafe extern "C" fn hs_terminate_workflow_execution(
});
}

// TODO: [publish-crate]
/// # Safety
///
/// Haskell <-> Tokio FFI bridge invariants.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hs_delete_workflow_execution(
client: *mut ClientRef,
c_call: *const RpcCall,
mvar: *mut MVar,
cap: Capability,
error_slot: *mut *mut CRPCError,
result_slot: *mut *mut CArray<u8>,
) {
let client = unsafe { &mut *client };
let mut retry_client = client.retry_client.clone();
let call: TemporalCall = unsafe { (&*c_call).into() };

let callback: HsCallback<CArray<u8>, CRPCError> = HsCallback {
cap,
mvar,
result_slot,
error_slot,
};
client.runtime.future_result_into_hs(callback, async move {
match rpc_call!(retry_client, call, delete_workflow_execution) {
Ok(resp) => Ok(CArray::c_repr_of(resp).unwrap()),
Err(err) => Err(err),
}
});
}

// TODO: [publish-crate]
/// # Safety
///
Expand Down
14 changes: 14 additions & 0 deletions core/src/Temporal/Core/Client/WorkflowService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Temporal.Core.Client.WorkflowService (
countWorkflowExecutions,
createSchedule,
deleteSchedule,
deleteWorkflowExecution,
deprecateNamespace,
describeNamespace,
describeSchedule,
Expand Down Expand Up @@ -580,6 +581,19 @@ terminateWorkflowExecution :: Client -> TerminateWorkflowExecutionRequest -> IO
terminateWorkflowExecution = call @WorkflowService @"terminateWorkflowExecution" hs_terminate_workflow_execution


foreign import ccall "hs_delete_workflow_execution" hs_delete_workflow_execution :: PrimRpcCall


{- |
Deletes a closed workflow execution from storage.

This permanently removes the workflow execution history and all associated data.
This operation is irreversible and should be used with caution.
-}
deleteWorkflowExecution :: Client -> DeleteWorkflowExecutionRequest -> IO (Either RpcError DeleteWorkflowExecutionResponse)
deleteWorkflowExecution = call @WorkflowService @"deleteWorkflowExecution" hs_delete_workflow_execution


foreign import ccall "hs_update_namespace" hs_update_namespace :: PrimRpcCall


Expand Down
32 changes: 32 additions & 0 deletions sdk/src/Temporal/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module Temporal.Client (
ResetReapplyExcludeType (..),
EventId (..),
resetWorkflowExecution,
deleteWorkflowExecution,

-- * Querying Workflows
QueryOptions (..),
Expand Down Expand Up @@ -936,6 +937,37 @@ describeWorkflowExecution h = do
)


{- | Permanently delete a closed workflow execution from storage.

This operation removes the workflow execution history and all associated data from storage.
This is irreversible and should be used with caution. The workflow must be closed (completed,
failed, terminated, etc.) before it can be deleted.

Note: This operation requires appropriate permissions and may not be available in all
Temporal deployments.
-}
deleteWorkflowExecution :: (MonadIO m) => WorkflowHandle a -> m ()
deleteWorkflowExecution h =
void do
res <-
liftIO $
WS.deleteWorkflowExecution
h.workflowHandleClient.clientCore
msg
case res of
Left err -> throwIO $ Temporal.Exception.coreRpcErrorToRpcError err
Right _ -> pure ()
where
msg =
defMessage
& RR.namespace .~ rawNamespace h.workflowHandleClient.clientConfig.namespace
& RR.workflowExecution
.~ ( defMessage
& Common.workflowId .~ rawWorkflowId h.workflowHandleWorkflowId
& Common.runId .~ maybe "" rawRunId h.workflowHandleRunId
)


data FollowOption = FollowRuns | ThisRunOnly


Expand Down